avoid-nested-shorthands
Warns when a dot shorthand invocation has an argument that is also a dot shorthand.
Nested dot shorthands significantly reduce readability (to a point where every instance is .new(.new(...))) and should be generally avoided.
Example
❌ Bad:
void fn() {
// LINT: Avoid nested dot shorthands as they significantly reduce readability. Try adding explicit types.
final Another a = .new(.new(version: .new('val')));
// LINT: Avoid nested dot shorthands as they significantly reduce readability. Try adding explicit types.
final a = Another(.new(version: .new('val')));
}
class SomeClass {
final String value;
const SomeClass(this.value);
}
class Some {
final SomeClass version;
const Some({required this.version});
}
class Another {
final Some some;
Another(this.some);
}
✅ Good:
void fn() {
final Another a = .new(Some(version: SomeClass('val')));
final a = Another(.new(version: SomeClass('val')));
}