Skip to content

Commit e707480

Browse files
docs:added information about trailing_commas and all its possibles v… (#7121)
fixes #6642 Added trailing_commas subsection with: Description of both available values (automate and preserve) Detailed explanation of each value's behavior (matching the text from the GitHub PR mentioned in the issue) Example YAML configuration showing both options together. This addresses the Issue #6642 by documenting the trailing_commas option and its possible values, making it clear to users how to configure this formatter behavior. @parlough @conooi @antfitch please review
1 parent a42d021 commit e707480

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/content/tools/analysis.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,11 +645,38 @@ analyzer:
645645
## Configuring `dart format`
646646

647647
You can configure the behavior of [`dart format`][] by adding a
648-
`formatter` section to the analysis options file
649-
specifying your preferred `page_width`.
648+
`formatter` section to the analysis options file.
649+
650+
### Configurable options
651+
652+
#### `page_width`
653+
654+
You can specify your preferred `page_width` (line length).
655+
The default is 80 characters.
650656

651657
For more information, read [Configuring formatter page width][].
652658

659+
#### `trailing_commas`
660+
661+
You can configure how the formatter handles trailing commas
662+
in argument and parameter lists
663+
using the `trailing_commas` option.
664+
It accepts one of two values:
665+
666+
`automate` (default)
667+
: The formatter adds and removes trailing commas based on
668+
its decision to split the surrounding construct.
669+
670+
`preserve`
671+
: A trailing comma forces the surrounding construct to split.
672+
The formatter adds a trailing comma when it splits a construct but does not remove one.
673+
674+
```yaml title="analysis_options.yaml"
675+
formatter:
676+
page_width: 120
677+
trailing_commas: preserve
678+
```
679+
653680
## Resources
654681

655682
Use the following resources to learn more about static analysis in Dart:

0 commit comments

Comments
 (0)