Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 742 Bytes

max-nested-destructuring.md

File metadata and controls

31 lines (21 loc) · 742 Bytes

Enforce a maximum depth that destructuring can be nested (max-nested-destructuring)

Variable declarations use destructuring in many cases. For some complex objects, nested destructuring may occur. The deeper the nesting, the less readable the code will be.

Options

This rule has an object option:

  • "max" (default 3) enforces a maximum depth that destructuring can be nested

Fail

const { foo: { bar: [{ baz }] } } = qux
/* eslint galaxy/max-nested-destructuring: ["error", { "max": 2 }] */
const { foo: { bar: { baz } } } = qux

Pass

const { foo: { bar: { baz } } } = qux
/* eslint galaxy/max-nested-destructuring: ["error", { "max": 2 }] */
const { foo: { bar: baz } } = qux