Skip to main content

no-empty-block

added in: 1.5.0
Free+
preset: recommended

Warns when a code block is empty.

Blocks with todo comments inside are not considered empty. Empty catch clause blocks are ignored by default.

Empty blocks are often indicators of missing code.

Example

❌ Bad:

// LINT: This block is empty. Try checking it for potentially missing code.
if (...) { }

[1, 2, 3, 4].forEach((val) {}); // LINT: This block is empty. Try checking it for potentially missing code.

void function() {} // LINT: This block is empty. Try checking it for potentially missing code.

✅ Good:

if ( ... ) {
// TODO(developername): need to implement.
}

[1, 2, 3, 4].forEach((val) {
// TODO(developername): need to implement.
});


void function() {
// TODO(developername): need to implement.
}

Additional Resources