Skip to content

Files

Latest commit

 

History

History
47 lines (35 loc) · 723 Bytes

no-empty.md

File metadata and controls

47 lines (35 loc) · 723 Bytes

Pattern: Empty block statement

Issue: -

Description

Empty block statements usually indicate incomplete refactoring or code that was removed without cleaning up the containing block. While not technically errors, they can cause confusion and should either be removed or documented with a comment explaining their purpose.

Examples

Example of incorrect code:

if (condition) {
}

while (condition) {
}

try {
  doSomething();
} catch(e) {
}

function foo() {
}

Example of correct code:

if (condition) {
  // Handle special case later
}

while (condition) {
  break;
}

try {
  doSomething();
} catch(e) {
  // Errors can be safely ignored
}

function foo() {
  return;
}