Lint Rules

noEmptyPattern (since v0.7.0)

This rule is recommended by Rome.

Disallows empty destructuring patterns.

Examples

Invalid

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

   Unexpected empty object pattern.
  
  > 1 │ var {} = foo;
       ^^
    2 │ 
  
var {a: {}} = foo;
correctness/noEmptyPattern.js:1:9 lint/correctness/noEmptyPattern ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Unexpected empty object pattern.
  
  > 1 │ var {a: {}} = foo;
           ^^
    2 │ 
  
function foo({}) {}
correctness/noEmptyPattern.js:1:14 lint/correctness/noEmptyPattern ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Unexpected empty object pattern.
  
  > 1 │ function foo({}) {}
                ^^
    2 │ 
  

Valid

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;