-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow lints to accept configurations #57673
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
@bwilkerson @pq wdyt ? |
Honestly, I have mixed feelings. On the one hand, this can be really useful and allow a much richer UX. But it's easy to abuse, and to end up with rules that are difficult to configure. I worked on a similar product at a previous company, and we made the mistake of adding configuration support. We didn't have outside contributions, so we had no one to blame but ourselves, but we ended up with a product that users couldn't use until they had spent multiple hours going through the list of lints to decide whether they wanted to use the lint and if so how to configure it. The task was so daunting that many of our customers never realized the full potential value of the product. So, yeah, it would be great to be able to specify the file header to a lint so that the quick fix could insert it when it's missing. On the other hand, I'm not convinced that it isn't better, for something like "include local variables in the lint" to just make them two separate lints and allow users to enable the functionality they want by choosing the lints they enable (something they have to do anyway). |
I always thought we'd do this (see for example this old tracking issue: #57153) but as time has gone on I'm not as keen (for the reasons that Brian cites). Very open to reconsidering though! |
I agree configuration should be an exception. And for a |
So the way to go as I see it is to introduce just a few super basic options to a linter rule which will not allow overconfiguring by design. A good example is the Ruby linter which introduces a few basic options for each rule: Here's how it looks: Layout/AccessModifierIndentation:
EnforcedStyle: outdent
IndentationWidth: 0
Layout/LineLength:
Exclude:
- config/**/*
Max: 80
Lint/EmptyBlock:
Exclude:
- spec/factories/**/*
Style/Lambda:
EnforcedStyle: literal |
FWIW, when trying to enable It'd be interesting to explore places that (judicious) configuration would really open up and weigh them against the downsides of the added complexity. Input welcome! |
Is the problem that |
Ah. Excellent point. If |
Yes, but it's structured the way it is because we're explicitly not making any guarantees about the API that it provides. Packages outside the SDK should never depend on it or import it. |
Understood. But isn't that what the In any event, probably more fuss than it's worth to get around a handful of |
I'm not aware of any enforcement of the convention (which might only exist for this one package), but yes, it's prefixed with an underscore to attempt to communicate that it's private. |
+1 to what Brian said about There are other approaches we could use instead, I suppose. For example, I agree with Phil that, at least in the case of |
As pointed in #59211, the behaviour of " I do believe that there could be one more option inside the Something similar to what we already have today with: analyzer:
plugins:
- dart_code_metrics
language:
strict-casts: true
exclude:
- "**.g.dart"
errors:
missing_required_param: error
# Added new option:
ignore_for_private_members:
- avoid_positional_boolean_parameters Or in the ignore something like: // ignore-for-private-members-in-file: avoid_positional_boolean_parameters That could also, at least help with #54374 main idea for example. |
Just pointing out this would be great if made around the same time as #57034, since they are about the same thing. |
It would be useful and nice to be able to customize some lints with parameter/configuration.
For instance:
The text was updated successfully, but these errors were encountered: