Skip to main content

noEmptyPattern

Disallows empty destructuring patterns.

Examples

Invalid

var {} = foo;
warning[noEmptyPattern]: Unexpected empty object pattern.
   noEmptyPattern.js:1:5
  
1  var {} = foo;
       --

var {a: {}} = foo;
warning[noEmptyPattern]: Unexpected empty object pattern.
   noEmptyPattern.js:1:9
  
1  var {a: {}} = foo;
           --

function foo({}) {}
warning[noEmptyPattern]: Unexpected empty object pattern.
   noEmptyPattern.js:1:14
  
1  function foo({}) {}
                --

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;