跳转到内容

noEmptyPattern

此内容尚不支持你的语言。

Diagnostic Category: lint/correctness/noEmptyPattern

Since: v1.0.0

Sources:

Disallows empty destructuring patterns.

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

Unexpected empty object pattern.

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

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

Unexpected empty object pattern.

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

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

Unexpected empty object pattern.

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

The following cases are valid because they create new bindings.

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