Closed mollykreis closed 1 year ago
We discussed in person and agreed that the curly rule set to all
is our best option for now. We would be ok with allowing just the single line if
syntax but there's no way to allow that without allowing undesirable syntaxes (the multi
config comes closest).
I realized while testing the fix for this in #87 that just using the curly
rule will still allow this syntax:
if (foo) { doSomething; }
Our options are:
curly
rule'brace-style': ['error', '1tbs', { allowSingleLine: false }]
in addition to curly
which forces the body and closing brace to be on subsequent lines.'brace-style': ['error', '1tbs', { allowSingleLine: false }]
but NOT curly, which allows single-line statements on the same line if they don't have braces.// Example A. Allowed by 3
if (foo) doSomething();
// Example B. Allowed by 3
if (foo) doSomethingConditionally(); doSomethingUnconditionallyButItLooksConditional();
// Example C. Allowed by 1
if (foo) { doSomething(); }
// Example D. Allowed by 1
if (foo) { doSomething(); doSomethingElse(); }
// Example E. Always disallowed by Airbnb config for non-block-statement-body-position
if (foo)
doSomething();
// Example F. Always allowed
if (foo) {
doSomething();
}
The original bug report requested 2. That's my vote too because I don't like permitting example B above and find the example C syntax ugly. But if anyone wants to argue for 1 or 3, we can discuss it again. @rajsite @mure @TrevorKarjanis
We agreed in person to require the body to be on a new line (option 2). @jattasNI to revive the PR to make this happen.
For consistency, the body of all blocks in javascript should require new lines and curly braces.
eg:
not
Note: This discussion originally started on this PR.