Skip to content

Files

Latest commit

 

History

History
60 lines (48 loc) · 681 Bytes

no-collapsible-if.md

File metadata and controls

60 lines (48 loc) · 681 Bytes

Pattern: Unmerged if statement

Issue: -

Description

Identifies nested if statements that can be combined into one.

Examples

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 {
}

Further Reading