Skip to content
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

core/recommended lints to support wildcard variables #832

Open
pq opened this issue Sep 3, 2024 · 3 comments
Open

core/recommended lints to support wildcard variables #832

pq opened this issue Sep 3, 2024 · 3 comments
Labels
package:lints type-question A question about expected behavior or functionality

Comments

@pq
Copy link
Member

pq commented Sep 3, 2024

Hey all.

As we wrap up analyzer support for wildcards, we've got some open questions about how we want the linter to behave to support (and nudge folks towards idiomatic use of) wildcards. What opinions would you all like to see enforced in the core or recommended sets?

Feel free to chime in here or dart-lang/sdk#56595

Thanks!

@pq pq added type-question A question about expected behavior or functionality type-lint labels Sep 3, 2024
@devoncarew
Copy link
Member

At least historically, these two lint sets tend to trail best practices. I.e., we've used a published recommendation in effective dart as a reason to add a lint to these two sets.

Though for some items we've adjusted the lint set to prep best practices for upcoming language changes (i.e., dart-lang/sdk#51221).

@lrhn
Copy link
Member

lrhn commented Sep 4, 2024

Post feature, I'll want a "no local _ variables" as a core lint.

The only places where _ names make sense are parameters (which you need to have for the signature, but don't need to reference the value of) and destructuring/pattern matching, and pattern matching has internalized _ already.

If you write var _ = 42;, you're missing some point somewhere. It's likely a mistake. That's enough for me to want a core lint to prevent it.
(If you write int _(int x) { return x; }, you're seriously missing something.

I don't know how I feel about avoid_renaming_method_parameters wrt. _. I'd personally be fine with using _ in an override, but I can see why someone using that lint may disagree.
I'd definitely be fine with an override using a real name where the superinterface used _. It's not a renaming when it started from nothing. It's just a naming.

Pre-feature, guiding people away from using _ as a variable name and referencing it is a good idea.
I'd just enable that as a language warning, no lint needed. We're going to change the language in a way that will make that code stop working. That's basically a deprecation warning.

@pq
Copy link
Member Author

pq commented Sep 5, 2024

Thanks!

I don't know how I feel about avoid_renaming_method_parameters wrt. _. I'd personally be fine with using _ in an override, but I can see why someone using that lint may disagree.

This is in fact how it's currently implemented. And as of dart-lang/sdk@4a7db83,

I'd definitely be fine with an override using a real name where the superinterface used _. It's not a renaming when it started from nothing. It's just a naming.

this too.

@mosuem mosuem transferred this issue from dart-lang/lints Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:lints type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

4 participants