dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
628 stars 170 forks source link

Apply `directives_ordering` to `part` #4945

Closed FMorschel closed 3 weeks ago

FMorschel commented 5 months ago

Describe the issue There is the directives_ordering. It does not apply to part, only import and export.

To Reproduce

linter:
  rules:
    directives_ordering: true
part 'b.dart';
part 'a.dart';

Expected behavior To trigger directives_ordering lint.

Additional context If you disagree with adding this rule to directives_ordering, then maybe we could create a new linter to that.

bwilkerson commented 5 months ago

It does seem reasonable to me that the lint should check part directives.

pq commented 3 weeks ago

Chatting w/ @jakemac53, sorting parts is not something we can safely do in a world with augmentations because then order matters.

Because of that, I don't think we want to go ahead with this after all.

FMorschel commented 3 weeks ago

I'm not familiar with augmentations yet, but can't the analyzer see if this is being used to apply the suggestion only when it is not? Or would it be weird to do so?

jakemac53 commented 3 weeks ago

Fwiw, it is possible to determine when it is safe to do. But, implementing that might not be worth while (or spending the compute on it). It is safe if any of the following are true:

But, it doesn't feel right for this lint to be computing all of that, when today it can operate on just a single parsed AST.

FMorschel commented 3 weeks ago

Thats understandable. Could you please link here some docs for augmentations so I can see what you are talking about? And if there is nothing else you'd like to discuss here we can close this issue.

jakemac53 commented 3 weeks ago

https://github.com/dart-lang/language/blob/main/working/augmentation-libraries/feature-specification.md