implement adjustable bracestyle - #3
Conversation
im not quite sure why this isnt already here in the original repo or the fork?
|
@dolumchei, the reason is simple: the formatter positions itself as an opinionated, like prettier and csharpier. These formatters don't allow for options at all, beyond some extremely basic ones. That's the point of The author of the formatter picks one format they like and everyone using it have to comply or pick a different one formatter. The official doc explicitly mentions that the control flow structures are always formatted in one way: At this point, I'm not ready to add this option, because it feels like opening a pandora box for the rest of the formatting logic. Even the options I do provide right now, are mostly there for backward compatibility with my own project that uses this formatter, just so I don't explode the entire codebase in one go. P.S. I also want to note, that having no braces, per your example, in a JS-ES3-eske language (not Python or something) looks like a coding warcrime, and I don't condone that. That's precisely why this formatter exists. That's what I personally think. I like my JS hugged with cozy-brackets. |

im not quite sure why this isnt already here in the original repo or the fork?
i also wouldve implemented something like "minimal"
`
// Without Minimal
if (value == 0)
{
do_thing();
}
// With Minimal
if (value == 0)
do_thing();
`
Summary by cubic
Adds an adjustable brace style setting to the Playground so users can choose how braces are formatted. Persists the selection by serializing
BraceStyleinFormatOptions.FormatOptions.BraceStylebindable/serializable by removingJsonIgnoreand assigning explicit enum values (SameLine = 0,NewLine = 1).Written for commit 889a38f. Summary will update on new commits.