src/content/docs/linter/rules/no-empty-block-statements.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.3.0` - Diagnostic Category: [`lint/suspicious/noEmptyBlockStatements`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Same as [`no-empty`](https://eslint.org/docs/latest/rules/no-empty) - Same as [`no-empty-static-block`](https://eslint.org/docs/latest/rules/no-empty-static-block) - Same as [`no-empty-function`](https://eslint.org/docs/latest/rules/no-empty-function) - Same as [`@typescript-eslint/no-empty-function`](https://typescript-eslint.io/rules/no-empty-function){
"linter": {
"rules": {
"suspicious": {
"noEmptyBlockStatements": "error"
}
}
}
}
Disallow empty block statements and static blocks.
Empty static blocks and block statements, while not technically errors, usually occur due to refactoring that wasn’t completed. They can cause confusion when reading code.
This rule disallows empty block statements and static blocks. This rule ignores block statements or static blocks which contain a comment (for example, in an empty catch or finally block of a try statement to indicate that execution should continue regardless of errors).
function emptyFunctionBody () {}
try {
doSomething();
} catch(ex) {
}
class Foo {
static {}
}
function foo () {
doSomething();
}
try {
doSomething();
} catch (ex) {
// continue regardless of error
}