Skip to content

emptyBlocks

Reports empty block statements that should contain code.

✅ This rule is included in the ts stylistic preset.

Empty blocks can indicate incomplete code or areas where logic was removed but the block structure was left behind. They can also reduce code readability by cluttering the codebase with unnecessary braces.

This rule does not report empty function, method, constructor, or accessor bodies, as these are common patterns for abstract methods, stubs, or interfaces. Empty catch blocks are also allowed when they contain comments explaining why the error is being ignored.

if (condition) {
}
while (condition) {}
for (let i = 0; i < 10; i++) {}
switch (value) {
}

This rule is not configurable.

If your codebase frequently uses empty blocks as placeholders during development, you might find this rule too strict. However, it’s generally better to add comments to empty blocks to explain their purpose.

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