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.
Examples
Section titled “Examples”class Example { static {}
static property = 1;}
class Example { static property = 1;}
class Example { static { this.property = 1; }}
Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noEmptyBlockStatements
- ESLint:
no-empty-static-block
- Oxlint:
eslint/no-empty-static-block
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.