Consider this code;
while (condition) yield aBigCall({
the: "expression",
spans: "many",
lines,
})
when formatting with useBraces: "preferNone";
while (condition) {
yield aBigCall({
the: "expression",
spans: "many",
lines,
})
}
however my desired output is the exact same as the input. My philosophy is;
- I should not write any code that is redundant
- statements whose bodies contain only one expression/statement do not need braces
- braces on such statements are redundant
- I should not write braces on such statements
It would be nice to have an option which refuses to add or keep braces if they only enclose a single expression, regardless of whether that expression spans 3 characters or a million lines.
To me, this is what preferNone means; "prefer to use no braces, unless the code would behave incorrectly without them."
The current implementation of preferNone seems to be; "prefer to [...] without them or the code matches one of these arbitrary cases." This isn't preferring none, but instead preferring a particular opinionated style.
I would like to request another option asNeeded which will only permit braces where strictly necessary for functionality, and will enforce that single-expression bodies are not braced.
Consider this code;
when formatting with
useBraces: "preferNone";however my desired output is the exact same as the input. My philosophy is;
It would be nice to have an option which refuses to add or keep braces if they only enclose a single expression, regardless of whether that expression spans 3 characters or a million lines.
To me, this is what
preferNonemeans; "prefer to use no braces, unless the code would behave incorrectly without them."The current implementation of
preferNoneseems to be; "prefer to [...] without them or the code matches one of these arbitrary cases." This isn't preferring none, but instead preferring a particular opinionated style.I would like to request another option
asNeededwhich will only permit braces where strictly necessary for functionality, and will enforce that single-expression bodies are not braced.