Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 532 Bytes

no-collapsible-if.md

File metadata and controls

52 lines (44 loc) · 532 Bytes

no-collapsible-if

Identifies nested if statements that can be combined into one.

Also use no-unnecessary-else to further reduce block nesting.

Not passing:

/* 1 */
if (foo)
  if (bar);
/* 2 */
if (foo) {
  if (bar) {
  }
}
/* 3 */
if (foo) {
} else {
  if (bar) {
  } else {
  }
}

Passing:

/* 1 */
if (foo && bar);
/* 2 */
if (foo && bar) {
}
/* 3 */
if (foo) {
} else if (bar) {
} else {
}

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

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