no-empty-static-block

Disallow empty static {} blocks in classes

warn by defaulthas suggestions

A static block runs once, when the class is defined. An empty one does nothing. It's usually something a refactor left behind, or setup code that was never written.

A block with a comment in it isn't reported.

This rule is on by default.

Configure#

On by default as a warning. To turn it off:

bunfig.toml
[lint.rules]
"no-empty-static-block" = "off" # or "error"

Examples#

example.js1 problem
class Config {
  static values = new Map();

  static {}
}
example.jsNo problems
class Config {
  static values = new Map();

  static {
    Config.values.set("mode", process.env.NODE_ENV);
  }
}
example.jsNo problems
class Config {
  static {
    // Values are loaded on first use.
  }
}