Skip to content

Latest commit

 

History

History

plugin-extract-object-properties

@putout/plugin-extract-object-properties NPM version

The destructuring assignment makes possible to unpack values from objects into distinct variables.

(c) MDN

🐊Putout plugin adds ability to apply destructuring to extract object properties.

Install

npm i @putout/plugin-extract-object-properties -D

Rule

{
    "rules": {
        "extract-object-properties/equal-deep": "on",
        "extract-object-properties/not-equal-deep": "on"
    }
}

Equal Deep

❌ Example of incorrect code

const {replaceWith} = a.operate;
const {isIdentifier} = a.types;

✅ Example of correct code

const {operator, types} = a;

const {replaceWith} = operator;
const {isIdentifier} = types;

Not Equal Deep

❌ Example of incorrect code

const {replaceWith} = a;
const {isIdentifier} = a.types;

✅ Example of correct code

const {replaceWith, types} = a;

const {isIdentifier} = types;

License

MIT