Skip to content

emptyStaticBlocks

Reports empty static initialization blocks within class declarations.

✅ This rule is included in the ts stylistic preset.

Static blocks are used to initialize static class properties or perform other one-time setup when a class is loaded. An empty static block contains no statements and therefore serves no purpose. Removing empty static blocks keeps code cleaner and easier to maintain.

class Example {
static {}
static property = 1;
}

This rule is not configurable.

Some projects choose to standardize some classes with the same static blocks, even if those blocks are empty. If you prefer that kind of strict stylistic standardization over conciseness then this rule might not be for you.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.