Hello,
In 16.1, it says:
Use braces with all multi-line blocks.
But in the examples, there's a contradiction:
// good
if (test) return false;
And
// bad
function foo() { return false; }
The second one shouldn't say 'bad' since it's not multi-line block like the rule says.
The first example is permitted since it's a single-line block.
I agree we should remove the second example.
However, I think perhaps we should rewrite this section to always require braces in every scenario, period. Too many bugs are caused by omitting braces, and adding a second line intending it to be indented under the conditional.
Isn't it a little redundant to say that you should include braces with multi-line blocks since a block cannot have multiple lines without braces?
In this case, "multi-line block" is referring to "whatever the user thinks is a block" - which will only require braces if they understand how blocks work. Someone coming from a significant-whitespace language, for example, may not understand that difference.
this goes way back to 2012 https://github.com/airbnb/javascript/pull/3
Most helpful comment
The first example is permitted since it's a single-line block.
I agree we should remove the second example.
However, I think perhaps we should rewrite this section to always require braces in every scenario, period. Too many bugs are caused by omitting braces, and adding a second line intending it to be indented under the conditional.