[Linter] Proposal: prefer_wildcard_variables
lint rule
#59638
Labels
devexp-linter
Issues with the analyzer's support for the linter package
legacy-area-analyzer
Use area-devexp instead.
linter-lint-proposal
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
Proposal for New Dart Lint Rule
TLDR
Add a lint rule to prefer wildcard variables (
_
) over multiple underscores (_, __, ___
) in unused parameters.Motivation
The upcoming Dart 3.7.0 release introduces support for wildcard variables (
_
) that can be reused for multiple unused parameters. Previously, developers commonly relied on distinct variables like_, __, ___
to indicate unused parameters. This practice is now redundant with the introduction of_
, which improves clarity and reduces visual noise in the codebase.Reference
Lint Rule Implementation
Rule Name:
prefer_wildcard_variables
Description: Warns when distinct variable names such as
__, ___, etc.
are used for unused parameters, recommending the use of_
instead.Severity Level: WARNING (as it’s a stylistic improvement and non-breaking).
Code Examples
Bad
Good
Behavior
__, ___
) are declared.(_, _, _)
.Benefits
_
,__
, and___
might accidentally be referenced or misinterpreted.The text was updated successfully, but these errors were encountered: