avoid-redundant-positional-field-name
preset: recommended
Warns when a record positional field has a name.
Record positional field names do not affect code suggestions, but add extra noise with little benefit. Consider using named fields instead.
warning
This rule is not compatible with match-positional-field-names-on-assignment
.
Example
❌ Bad:
class MyClass {
(int x, int y) getPoint() => (1, 1); // LINT: Adding a name to the positional field has no effect. Try converting to named or removing the name.
(int x, {int y}) getPointPartiallyNamed() => (1, y: 1); // LINT: Adding a name to the positional field has no effect. Try converting to named or removing the name.
}
✅ Good:
class MyClass {
(int,) calculate() => (0,);
({int x, int y}) getPointNamed() => (x: 1, y: 1); // Correct, both fields are named
({int x, int y}) getPointPartiallyNamed() => (x: 1, y: 1);
}