unicorn/empty-brace-spaces
Disallow spaces and line breaks inside empty braces
fixable
You can write an empty pair of braces as {}, { } or over two lines. This rule keeps {}, so empty objects, blocks, function bodies and class bodies look the same everywhere.
Braces with a comment in them aren't empty, so they're left alone.
--fix removes the whitespace.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/empty-brace-spaces" = "error" # or "warn"Examples#
example.js3 problems
const cache = { }No spaces inside empty pair of braces allowed;
function noop() {No spaces inside empty pair of braces allowed
}
class Store { }No spaces inside empty pair of braces allowedexample.jsNo problems
const cache = {};
function noop() {}
class Store {}
try {
cache.clear();
} catch {
// Nothing to clean up.
}