-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
proposal: consider a unnecessary_library_names
lint
#58950
Comments
My take:
Something like this: const _name = 'unnecessary_library_name';
const _desc =
'Avoid library names.';
const _details = r'''
From the [style guide](https://dart.dev/guides/language/effective-dart/style#dont-explicitly-name-libraries):
**DON'T** explicitly name libraries by attaching a name to a library directive.
**BAD:**
library my_library;
**GOOD:**
library;
''';
// ....
class UnnecessaryLibraryName extends LintRule {
static const LintCode code = LintCode(
_name,
'Library directives should not have names.',
correctionMessage: 'Try deleting the library name.',
); (not set on |
I think we're in agreement so I'm bumping this to "accepted". Chime in if you have reservations! |
I also prefer the name But I have a question: will the lint still fire if the library has parts and at least one of the parts uses the name of the library? I'd kind of prefer that the answer be "yes", and we can easily automate converting the part-of directive to use a URL, but it is harder for users to update manually and there are code generators that might still be using names. I'd like to see a more complete specification before we mark this as accepted. |
no_library_names
lintunnecessary_library_names
lint
I don't think we care too much either way. We already have https://dart.dev/tools/linter-rules/use_string_in_part_of_directives in our core set and any project which is conformant to this one will not be impacted either way by this decision. Whichever is easier to implement should be fine. If it's easy enough to allow library names when there is a part relying on that name I'd lean towards doing that since it might be less confusing in edge cases, but I wouldn't bother if it's significantly more effort. |
I'd be fine with just saying "no library names" and not checking for whether they are used. Possible definition:
When it comes to library names, the only winning move is not to play. |
It looks like we're shooting to include this in the next |
Fixes: https://github.com/dart-lang/linter/issues/3882 (I'll follow-up with a quick-fix.) Change-Id: Ice88bfb59a16163b003ce94c73e057d2fd968a9d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358561 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
Implemented w/ 7145659 Quick-fix in flight: https://dart-review.googlesource.com/c/sdk/+/358681 |
Current guidance discourages named libraries (dart-lang/site-www@dbac48c) and we should consider a lint to support the advice.
Related lints:
/fyi @MaryaBelanger @munificent @srawlins
The text was updated successfully, but these errors were encountered: