# @putout/plugin-apply-destructuring

> 🐊Putout plugin adds ability use destructuring on variable declarations

Latest version **10.1.1** (published 2025-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @putout/plugin-apply-destructuring
pnpm add @putout/plugin-apply-destructuring
yarn add @putout/plugin-apply-destructuring
bun add @putout/plugin-apply-destructuring
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 10.1.1 |
| Published | 2025-11-28 |
| First published | 2019-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 796 |
| Author | coderaiser |
| Maintainers | coderaiser |
| Keywords | putout, putout-plugin, plugin, destructuring |

## Links

- npm: https://www.npmjs.com/package/@putout/plugin-apply-destructuring
- Repository: https://github.com/coderaiser/putout
- Homepage: https://github.com/coderaiser/putout/tree/v40.15.1/packages/plugin-apply-destructuring#readme
- Issues: https://github.com/coderaiser/putout/issues
- npm.io page: https://npm.io/package/@putout/plugin-apply-destructuring

## Recent versions

- 10.1.1 (latest) — 2025-11-28
- 10.1.0 — 2025-11-14
- 10.0.0 — 2025-09-17
- 9.0.0 — 2025-04-04
- 8.0.1 — 2025-02-27
- 8.0.0 — 2025-02-27
- 7.1.0 — 2023-06-07
- 7.0.0 — 2023-05-11
- 6.1.0 — 2023-02-23
- 6.0.0 — 2023-02-23
- 5.3.0 — 2022-09-06
- 5.2.1 — 2021-04-22
- 5.2.0 — 2021-04-22
- 5.1.1 — 2021-03-25
- 5.1.0 — 2021-01-21
- … 13 more at https://npm.io/package/@putout/plugin-apply-destructuring/versions

## README

# @putout/plugin-apply-destructuring [![NPM version][NPMIMGURL]][NPMURL]

[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-apply-destructuring.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-apply-destructuring"npm"

> The **destructuring** assignment syntax is a **JavaScript** expression that makes it possible to unpack values from arrays, or properties 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 use **destructuring** on variable declarations. Renamed to [`@putout/plugin-destructuring`](https://www.npmjs.com/package/@putout/plugin-destructuring).

## Install

```
npm i @putout/plugin-apply-destructuring
```

## Rules

- ✅ [object](#object);
- ✅ [array](#array);
- ✅ [falsy](#falsy);
- ✅ [convert-object-to-array](#convert-object-to-array);

## Config

Short:

```json
{
    "rules": {
        "apply-destructuring": "on"
    }
}
```

Full:

```json
{
    "rules": {
        "apply-destructuring/object": "on",
        "apply-destructuring/array": "on",
        "apply-destructuring/falsy": "on"
    }
}
```

## array

## ❌ Example of incorrect code

```js
const first = array[0];
```

## ✅ Example of correct code

```js
const [first] = array;
```

## object

## ❌ Example of incorrect code

```js
const name = user.name;

hello = world.hello;
```

## ✅ Example of correct code

```js
const {name} = user;

({hello} = world);
```

## falsy

Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c9ed04b421d75ae39e58038fa6e14630/4c097e3173990ec7e5ebabbe2cedf8e952092ebf).

## ❌ Example of incorrect code

```js
const {maxElementsInOneLine} = {
    options,
};
```

## ✅ Example of correct code

```js
const {maxElementsInOneLine} = options;
```

## convert-object-to-array

Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a1d26daf8bb83ee3ea1c0b62a6ad3afd/cef9b4d27c9dbb0d413a935b0359a6fe9b50364f).

## ❌ Example of incorrect code

```js
const {0: a, 1: b} = c;
```

## ✅ Example of correct code

```js
const [a, b] = c;
```

## License

MIT

---
_Source: https://npm.io/package/@putout/plugin-apply-destructuring · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
