Skip to content
← Back to rules

eslint/no-empty-static-block Correctness

✅ This rule is turned on by default.
💡 A suggestion is available for this rule.

What it does ​

Disallow empty static blocks.

Why is this bad? ​

Empty block statements, while not technically errors, usually occur due to refactoring that wasn’t completed. They can cause confusion when reading code.

Examples ​

Examples of incorrect code for this rule:

js
class Foo {
  static {}
}

Examples of correct code for this rule:

js
class Foo {
  static {
    // blocks with comments are allowed
  }
}
class Bar {
  static {
    doSomething();
  }
}

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "no-empty-static-block": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "no-empty-static-block": "error",
  },
});
bash
oxlint --deny no-empty-static-block

Version ​

This rule was added in v0.0.19.

References ​