unnecessary-trailing-comma
preset: recommended
Checks for unnecessary trailing commas for arguments, parameters, enum values and collections.
Removing those commas results in dart format
producing code that fits on one line.
⚙️ Config
Set max-width
(default is 80
) to configure a custom max line width.
Set multiline
(default is false
) to highlight an unnecessary comma for arguments that take more than one line and are last.
Set trailing-lists
(default is false
) to highlight an unnecessary comma for list, set or map literals that are the last argument of an invocation.
dart_code_metrics:
...
rules:
...
- unnecessary-trailing-comma:
max-width: 100
Example
❌ Bad:
// LINT
void function(
String first,
String second,
) {
return;
}
✅ Good:
void function(String first, String second) {
return;
}