const {} = user looks like a declaration but doesn't create a variable. The usual cause is one wrong character. { settings: {} } destructures settings into nothing, while { settings = {} } would give it a default value.
This rule is on by default.
Configure
On by default as a warning. To turn it off:
bunfig.toml
[lint.rules]
"no-empty-pattern" = "off" # or "error"
Every option, set to its default:
bunfig.toml
[lint.rules]
"no-empty-pattern" = ["warn", {
allowObjectPatternsAsParameters = true,
}]
Examples
Reported:
const { settings: {} } = user;
const [] = items;
function render([]) {
return "<div></div>";
}
Not reported:
const { settings = {} } = user;
const [first] = items;
function render({ title }) {
return `<div>${title}</div>`;
}
Options
| Option | Default | What it does |
|---|---|---|
allowObjectPatternsAsParameters | true | Allow {} as a function parameter, with no default value or with the default {}. |
This is for a function that's called with an object it doesn't need, but that uses a later parameter. Playwright requires the {} in a fixture that uses no other fixture. With an ESLint config file the default is ESLint's, false.
function withServer({}, use) {
return use(startServer());
}
function withDatabase({} = {}, use) {
return use(openDatabase());
}
function withServer({}, use) {
return use(startServer());
}
An empty array pattern as a parameter is still reported:
function withServer([], use) {
return use(startServer());
}