@putout/plugin-split-nested-destructuring

3.0.0 • Public • Published

@putout/plugin-split-nested-destructuring NPM version

  • Don't use nested destructuring on data that comes from any external data sources (such as REST APIs, GraphQL endpoints or files).
  • Don't use nested destructuring on function arguments that have long or complicated signatures.

(c) Destructuring in JavaScript: the not so good parts

🐊Putout plugin adds ability to split nested destructuring.

Install

npm i @putout/plugin-split-nested-destructuring -D

Rule

{
    "rules": {
        "split-nested-destructuring": "on"
    }
}

Example of incorrect code

const {
    a: {
        b,
    },
    a: {
        b: x,
    },
} = c;

function f({a: {b}}) {
    console.log(b);
}

Example of correct code

const {a} = c;
const {b, b: x} = a;

function f({a}) {
    const {b} = a;
    console.log(b);
}

License

MIT

Package Sidebar

Install

npm i @putout/plugin-split-nested-destructuring

Weekly Downloads

15,179

Version

3.0.0

License

MIT

Unpacked Size

5.13 kB

Total Files

4

Last publish

Collaborators

  • coderaiser