@putout/plugin-extract-object-properties
Version:
πPutout plugin adds ability to extract object properties into variable
67 lines (45 loc) β’ 1.47 kB
Markdown
# @putout/plugin-extract-object-properties [![NPM version][NPMIMGURL]][NPMURL]
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-extract-object-properties.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-extract-object-properties "npm"
> The **destructuring assignment** makes possible to unpack values from objects into distinct variables.
>
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)
π[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to apply destructuring to extract object properties. Merged with [`@putout/plugin-destructuring`](https://www.npmjs.com/package/@putout/plugin-destructuring).
## Install
```
npm i @putout/plugin-extract-object-properties -D
```
## Rule
```json
{
"rules": {
"extract-object-properties/equal-deep": "on",
"extract-object-properties/not-equal-deep": "on"
}
}
```
## Equal Deep
### β Example of incorrect code
```js
const {replaceWith} = a.operate;
const {isIdentifier} = a.types;
```
### β
Example of correct code
```js
const {operator, types} = a;
const {replaceWith} = operator;
const {isIdentifier} = types;
```
## Not Equal Deep
### β Example of incorrect code
```js
const {replaceWith} = a;
const {isIdentifier} = a.types;
```
### β
Example of correct code
```js
const {replaceWith, types} = a;
const {isIdentifier} = types;
```
## License
MIT