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.
This rule has an object option:
"max"
(default3
) enforces a maximum depth that destructuring can be nested
const { foo: { bar: [{ baz }] } } = qux
/* eslint galaxy/max-nested-destructuring: ["error", { "max": 2 }] */
const { foo: { bar: { baz } } } = qux
const { foo: { bar: { baz } } } = qux
/* eslint galaxy/max-nested-destructuring: ["error", { "max": 2 }] */
const { foo: { bar: baz } } = qux