-
Notifications
You must be signed in to change notification settings - Fork 1.7k
proposal: unnecessary_library_directive
#58870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The lint should not flag library directives if the library has parts that use the library name in the |
Although folks should NOT be using parts with library names anymore, too – right? RE https://dart-lang.github.io/linter/lints/use_string_in_part_of_directives.html |
A library directive is needed if:
The last point is undecidable, so basically a library declaration with a name cannot be considered guaranteed unnecessary. I'd still be fine with linting the declaration if the only use is (potentially) using Separately, the library name itself can be unnecessary. |
FYI: the associated language feature has LANDED for Dart 1.19! |
I've made a stab at implementing this – feedback welcome! dart-archive/linter#3791 |
avoid_library_directive
unnecessary_library_directive
Implemented w/ dart-archive/linter#3791 🎉 |
unnecessary_library_directive
Description
The library directive at the top of...libraries...is generally superfluous – UNLESS it's used to "anchor" a doc comment or an annotation (see #58871).
The use of the "naked" library directives should be avoided.
Details
Not much more than the description.
Kind
Style
Good Examples
Bad Examples
Discussion
See dart-lang/language#1073 for the no-name library directive proposal.
Would "conflict" with the following lints. No point in enforcing conventions for names when we want to avoid library directives!
This could likely be added to Effective Dart, I think.
Discussion checklist
The text was updated successfully, but these errors were encountered: