dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.31k stars 1.59k forks source link

directives_ordering lint message should say how it wants the imports sorted #58386

Open zanderso opened 3 years ago

zanderso commented 3 years ago

The errors currently in the Flutter framework on the Engine -> Framework roll look lik

In sample starting at packages/flutter/lib/src/cupertino/context_menu.dart:77:import 'package:flutter/cupertino.dart';
>>> info: Sort directive sections alphabetically (directives_ordering)

Fixing these would be much easier if the lint told me how it was expecting the imports to look.

/cc @pq

pq commented 3 years ago

The easiest way to fix this is in the IDE (using "Organize Imports..." or similar) or from the command line using dart fix. That said, I'm really sorry these issues keep popping up. I'll follow-up to better understand where I misstepped.

zanderso commented 3 years ago

The case that was happening here, where an IDE probably would not help, was directives not being sorted in generated code noted in text logs on CI.

navaronbracke commented 1 year ago

@pq Sadly this lint does not end up with fixes in dart fix?

For example:

navaronbracke@MacBook-Pro-van-Navaron weforza % dart analyze .
Analyzing ....                         4.0s

   info • lib/model/image/io_pick_image_delegate.dart:9:1 • Sort directive sections alphabetically. Try sorting the directives. •
          directives_ordering
   info • lib/native_service/io_file_storage_delegate.dart:8:1 • Sort directive sections alphabetically. Try sorting the directives.
          • directives_ordering
   info • lib/widgets/pages/export_data_page/export_data_file_name_text_field.dart:10:1 • Sort directive sections alphabetically. Try
          sorting the directives. • directives_ordering
   info • lib/widgets/pages/export_data_page/export_data_page.dart:15:1 • Sort directive sections alphabetically. Try sorting the
          directives. • directives_ordering
   info • lib/widgets/pages/ride_attendee_scanning_page/generic_scan_error.dart:8:1 • Sort directive sections alphabetically. Try
          sorting the directives. • directives_ordering

5 issues found.
navaronbracke@MacBook-Pro-van-Navaron weforza % dart fix --dry-run
Computing fixes in weforza (dry run)... 2.7s
Nothing to fix!
navaronbracke@MacBook-Pro-van-Navaron weforza % 

I'll file an issue for that bug.