-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Wildcard Variables][lint] no_wildcard_variable_uses
and the new wildcard variables feature.
#59470
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
no_wildcard_variable_uses
and the new wildcard variables feature.no_wildcard_variable_uses
and the new wildcard variables feature.
One change that would make sense would be to change the documentation:
to something like
... and then something about how names of the form |
I mentioned this possibility in the kick-off meeting, but I'll mention it again. Unless I'm mistaken, the wildcard variables feature is a breaking change. I don't know whether the next stable release is expected to be the point at which we introduce this breaking change or whether we're going to hold off shipping the feature until we have a few more breaking changes to bundle with it, but if the plan is the latter then we might want to consider making the warning about If that's the case, then the next question becomes whether we should deprecate the lint or whether we should leave it in place (but no longer warning about |
+1 to making the warning about |
For the lint, I'd personally want to warn about every I'll want the lint to say: Use It's a lint, it's allowed to be opinionated. If someone disagrees, they can |
If we change the |
Updated the original post with changes we'd like to see. The combination of the following (resulting from our discussion) will help users move to the new feature a lot more easily.
This issue will continue to track what's needed for |
Changes to make
(Updated May 14th 2024)
Wildcard parameters and local variables (whose name is '_' by definition) will become non-binding in a future version of the Dart language.
_
(not__
etc) if it's being used.UNUSED_VARIABLE
will have an additional fix to suggest converting to_
.As mentioned from dart-lang/language#3785 (comment).
https://dart.dev/tools/linter-rules/no_wildcard_variable_uses
no_wildcard_variable_uses
reports all named underscores, which is more than what we want.In the context of implementing the new wildcard variables feature (spec), what changes, if any, do we want to make to the
no_wildcard_variable_uses
lint?1. Migration/Breakage
One purpose of this existing lint is for an easier migration/breakage: which since it's enabled in the core lint set, should make the breakages across projects pretty small.
2. Wildcard variables feature
However, once the wildcard variables feature ships, we will most likely need to make a new lint and remove/deprecate(?)/change this one (because wildcards can be used :) ).
As @eernstg said, add a new lint that "targets the cases where
_
resolves to a declaration which would be wildcarded when that feature is enabled."cc. @pq
The text was updated successfully, but these errors were encountered: