-
Notifications
You must be signed in to change notification settings - Fork 28.5k
☂️ Update lint set for Flutter applications #78432
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
One comment:
If we do decide that we need a Flutter specific lint file (if we're not able to in-line everything into core and recommended), the flutter specific lints could just be shipped as part of the flutter package (e.g., packages/flutter/lib/flutter_recommended.yaml). |
I believe that would cause versioning issues: Whenever you upgrade your version of flutter you'd be forced to also upgrade your code base to the latest lints in |
It would definitely be a decision in terms of how we want these to roll out. We could version them with the sdk and ship changes as part of new stable versions. |
/fyi also @davidmorgan @bwilkerson |
Thanks everyone! Commented on the doc re: versioning. That model seems to work :) |
It is not clear to me why you'd need the double versioning (pub package version + yaml version). If the package doesn't contain any code, wouldn't it be enough to just use the package version? Whenever a new lint is added, it's treated as a breaking change and the MAJOR version number is bumped. If you're ready to upgrade to the latest set of recommended lints (and fix the warnings produced by it), you bump the package version in you package's pubspec. |
Sorry, my mistake--I checked: the analyzer has no problems resolving different yaml versions from different packages. Please ignore :) |
The reason for double-versioning is that it allows you to not use the most recent version of the lints. That's not important if the lints package is only a dev-dependency for all packages. If any package you depend on uses the lints package as a non-dev-dependency, you'll need to use a version accepted by that other package. If we make a change to the lints file, by adding a lint, your code might no longer be lint-warning-free. Some build systems might consider that an error. That means that you need to migrate your code to the new lints, and until then, you might want to keep your lints at the previous version. Again, if everybody uses the lints package as a dev-dependency only, you can just lock yourself to an older version of the lints package. If not, you might need to depend on a newer version of the lints package, and the versioned yaml files allows you to still use the older lints file. (Arguably, you can also just add |
The above was assuming that the package is added as a dev-dependency, which I think is the right thing to do for this package. If you don't do that correctly, it will cause problems, yes. But that's also true for other dev-dependencies that were accidentally added as a regular dependency, no? E.g. if I accidentally add package:test as a regular dependency I am also forcing the hands of other packages that depend on me... |
We know from |
Can we put something in a package's |
@jonasfj ? |
No such thing exists, but we could introduce it. I think it's a bit strong to say "never". Perhaps it's sufficient to introduce something that:
Maybe it's just as simple as having The downside of completely forbidding consumption as non-dev dependency is that any package intended to be used as a dev-dependency could certainly be used by another tool that is itself a dev-dependency. |
FWIW, I really like this proposal. 👍 |
SGTM. Prior art for is_dev_dependency: bazel's testonly attribute (no direct link, sorry, please search that table). Note that would suggest that an So e.g. This is a big step beyond the simple non-transitive version we need for lints yaml, but maybe worth a thought :) could be added to the simple version later, so doesn't need to block anything. |
Updated the top comment with the current status. |
@goderbauer I created tracking issues for the punted lints in the |
The main goal of this issue has been achieved, a migration guide for existing projects is published at https://flutter.dev/docs/release/breaking-changes/flutter-lints-package. What's left to do is to update DartPad (tracked in dart-lang/dart-pad#1881) and actively nudging existing/established projects to upgrade to I am going to close this umbrella issue since the main work is done and the remaining auxiliary work is tracked separately. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
The lints currently applied by
flutter analyze
to flutter applications created withflutter create
is outdated:analysis_options_user.yaml
received its last meaningful update in October 2019. This umbrella issue tracks the work necessary to update those lints and align the set of lints recommended for Flutter application with the Dart universe.Details of the approach are discussed in http://flutter.dev/go/flutter-lints.
Work Items
avoid_private_typedef_functions
fromcore.yaml
omit_local_variable_types
lint (Update: Removed fromrecommend.yaml
)core.yaml
,recommend.yaml
, and potentially a Flutter-specific lint file are published in a packageflutter create
to generate ananalysis_options.yaml
file importing the new recommended set of lints from that package (RFC: Integrate package:flutter_lints into templates #81417)analysis_options_user.yaml
with a message (duringflutter analyze
) to upgrade to a customanalysis_options.yaml
file importing the new recommended set of lintsPunted
We've decided to remove
unawaited_futures
andprefer_mixins
from the lint set for now so the following issues are no longer blocking and can be addressed later.unawaited_futures
lint is ready for Flutter code:Navigator
andAnimationController
methods, maybe others)prefer_mixins
lint is ready for Flutter code:ChangeNotifier
andWidgetsBindingObserver
, enable lint in flutter codebase for dogfooding/cc @pq @Hixie @mit-mit @munificent @devoncarew I think these are the work items that came out of our meeting the other day.
The text was updated successfully, but these errors were encountered: