Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 727 Bytes

multi-branch-curly.md

File metadata and controls

46 lines (36 loc) · 727 Bytes

Require following curly brace conventions for statements with multiple branches (multi-branch-curly)

Omitting the curly braces in an IfStatement can make code clearer sometimes, such as "return early". However, in cases where multiple branches are used, this can easily lead to misunderstandings due to inconsistencies.

This rule may conflict with ESLint's curly in some cases, so you may need to turn off the curly rule.

This rule is fixable.

Fail

if (foo) bar()
else baz()
function demo() {
  if (foo) {
    bar()
  } else return
}
if (foo) {
  baz()
} else if (bar)
  qux()
else {
  quix()
}

Pass

if (foo) bar()
if (foo) {
  bar()
} else {
  baz()
}