Skip to content

Files

Latest commit

 

History

History
33 lines (25 loc) · 696 Bytes

no-empty-pattern.md

File metadata and controls

33 lines (25 loc) · 696 Bytes

Pattern: Empty destructuring pattern

Issue: -

Description

Empty destructuring patterns ({} or []) have no effect and are usually a mistake. Often, developers intended to use a default value assignment (= {}) instead of an empty pattern, or forgot to specify the properties to destructure.

Examples

Example of incorrect code:

var {} = foo;
var [] = foo;
var {a: {}} = foo;
var {a: []} = foo;

function foo({}) {}
function bar([]) {}
function baz({a: {}}) {}

Example of correct code:

var {a = {}} = foo;
var [a = []] = foo;
var {a: {b}} = foo;
var {a: [x]} = foo;

function foo({a = {}}) {}
function bar([a = []]) {}
function baz({a: {b}}) {}