Project-wide formatting options for `dart format`
Asked Answered
D

0

4

I want to use dart format to format dart code, but my team uses custom format rules – such as line length of 120 characters and a few other things. Currently, code is formatted using settings in the IDE, but this is not ideal because it's not consistent across the team.

I know analysis_options.yaml can be used to configure static analysis, but I can't find a way to configure dart format to use the same rules.

Is there a way to configure dart format to use custom formatting rules?


Apparently, you can set line length by adding arguments dart format --line-length 240 .

I suppose the question is: What other options exist?

Dutra answered 4/10, 2023 at 16:54 Comment(5)
No github.com/dart-lang/dart_style/wiki/…Vicinity
@RichardHeap OP is asking for changing the line-length (which is configurable) project-wide (regardless of the individual developer's IDE settings). However, I don't think that's possible either.Undersize
Looks like there are actually command line args that work dart format --line-length 240 . I have not found documentation on what options are available.Dutra
I agree - I can't point you to the existing discussion without it automatically closing it. See also github.com/dart-lang/dart_style/issues/833Vicinity
There appear to be a few intentionally hidden options for dart format including line-length and indentation. github.com/dart-lang/dart_style/blob/…Dutra

© 2022 - 2024 — McMap. All rights reserved.