Skip to content

noEmptyPattern (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"correctness": {
"noEmptyPattern": "error"
}
}
}
}

Disallow empty object and array destructuring patterns.

Destructuring extracts values into new variables. An empty pattern extracts nothing and creates no variables, which is usually a mistake.

var {} = foo;
code-block.js:1:5 lint/correctness/noEmptyPattern ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Unexpected empty object pattern.

> 1 │ var {} = foo;
│ ^^
2 │

ℹ An empty pattern does not create any variables, but it can still throw an error for an invalid value.

ℹ Add the names you want to extract, or remove the pattern.

var {a: {}} = foo;
code-block.js:1:9 lint/correctness/noEmptyPattern ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Unexpected empty object pattern.

> 1 │ var {a: {}} = foo;
│ ^^
2 │

ℹ An empty pattern does not create any variables, but it can still throw an error for an invalid value.

ℹ Add the names you want to extract, or remove the pattern.

function foo({}) {}
code-block.js:1:14 lint/correctness/noEmptyPattern ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Unexpected empty object pattern.

> 1 │ function foo({}) {}
│ ^^
2 │

ℹ An empty pattern does not create any variables, but it can still throw an error for an invalid value.

ℹ Add the names you want to extract, or remove the pattern.

The following patterns are valid because they create at least one variable.

var {a = {}} = foo;
var {a, b = {}} = foo;
var {a = []} = foo;
function foo({a = {}}) {}
function foo({a = []}) {}
var [a] = foo;