dart-lang/linter

[Wildcard Variables] support for `no_leading_underscores_for_local_identifiers`

pq opened this issue · 4 comments

pq commented

The current implementation special-cases all underscore variations:

**EXCEPTION:**: An unused parameter can be named `_`, `__`, `___`, etc.  This is
common practice in callbacks where you are passed a value but you don't need
to use it. Giving it a name that consists solely of underscores is the idiomatic
way to indicate that the value isn't used.

With the wild card variables feature we might start reporting on __, ___, etc.

Note that making this change may result in newly reported diagnostics. The impact could have some reach since this is a recommended lint.

/fyi @kallentu @bwilkerson

lrhn commented

Agree on warning on __ etc.
The reason they are exempt no longer applies, you should just use _ everywhere.

+1 on warning on _.

I don't know how much we care, but I wonder if it would be a useful step to have a fix that turns __ into the wildcard _ because I'm sure that's what users are trying to do in most cases.

Yes, we should definitely have a fix. And we should care a lot because such a fix will help users migrate seamlessly to whatever version this language feature ships in.

pq commented

See also #5048.

We'll want to pick how and where to nudge to use wildcards (and not do over do it!)