disallowEmptyBlocks

Disallows empty blocks (except for catch blocks).

Type: Boolean or Object

Values:

  • true for default behavior (strict mode, no empty blocks allowed)
  • Object:
    • 'allExcept' array of exceptions:
      • 'comments' blocks containing only comments are not considered empty

JSHint: noempty

Example

"disallowEmptyBlocks": true
Valid
if ( a == b ) { c = d; }
try { a = b; } catch( e ){}
Invalid
if ( a == b ) { } else { c = d; }
Rule source
Test source