Skip to main content

no-empty-pattern

NOTE: this rule is part of the recommended rule set.
Enable full set in deno.json:
{ "lint": { "rules": { "tags": ["recommended"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{ "lint": { "rules": { "include": ["no-empty-pattern"], "exclude": ["no-empty-pattern"] } } }

Disallows the use of empty patterns in destructuring.

In destructuring, it is possible to use empty patterns such as {} or [] which have no effect, most likely not what the author intended.

Invalid:

// In these examples below, {} and [] are not object literals or empty arrays, // but placeholders for destructured variable names const {} = someObj; const [] = someArray; const {a: {}} = someObj; const [a: []] = someArray; function myFunc({}) {} function myFunc([]) {} 

Valid:

const { a } = someObj; const [a] = someArray; // Correct way to default destructured variable to object literal const { a = {} } = someObj; // Correct way to default destructured variable to empty array const [a = []] = someArray; function myFunc({ a }) {} function myFunc({ a = {} }) {} function myFunc([a]) {} function myFunc([a = []]) {} 

Did you find what you needed?