Skip to main content

js/noEmptyBlocks

disallow empty block statements

ESLint Equivalent: no-empty

Examples

Invalid

if (foo) {}

 file.ts:1:9 lint/js/noEmptyBlocks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid empty logic blocks.

    if (foo) {}
             ^^

  Empty logic blocks usually result from incomplete refactoring.


if (foo) {
	// foo;
} else {}

 file.ts:3:7 lint/js/noEmptyBlocks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid empty logic blocks.

    1if (foo) {
    2  // foo;
  > 3} else {}
            ^^

  Empty logic blocks usually result from incomplete refactoring.

Valid

if (foo) foo;
if (foo) {
	foo;
}
if (foo) {
	// empty
}