{"name":"@putout/plugin-destructuring","version":"2.1.1","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to transform destructuring","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-destructuring#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{},"keywords":["putout","putout-plugin","plugin","destructuring"],"devDependencies":{"@putout/eslint-flat":"^4.0.0","@putout/plugin-declare":"*","@putout/plugin-declare-before-reference":"*","@putout/plugin-esm":"*","@putout/plugin-minify":"*","@putout/plugin-nodejs":"*","@putout/plugin-printer":"*","@putout/plugin-putout":"*","@putout/plugin-tape":"*","@putout/plugin-variables":"*","@putout/test":"^15.0.0","eslint":"^10.0.0","eslint-plugin-putout":"^31.0.0","madrun":"^13.0.0","nodemon":"^3.0.1","superc8":"^12.0.0"},"peerDependencies":{"putout":">=42"},"license":"MIT","engines":{"node":">=22"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-destructuring@2.1.1","gitHead":"43b666f9c4f1f9c310de3013bb3bbca1d0cff28c","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"26.3.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-VC5u3n4aLF3T0GcsMhjS78vBV86JmAYzYsv7YefOTPYWD8a2ZAjf4r/mtnGx2W9yHvwKTZ9Hj5/7xHXH4ECtDQ==","shasum":"61034b756e5c074f47b043ba1a121b2b2e0e45cf","tarball":"http://registry-npm.ywwl.com/@putout/plugin-destructuring/download/@putout/plugin-destructuring-2.1.1.tgz","fileCount":16,"unpackedSize":27054,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAf+VKhigsZ+1dtzTatmtg+eX4o3rAf7IHglqaNfbbW3AiEAw/oQVPz0W2bTOWD3ox3qVTsf/2K7DL1/0ZVhJsCcrV0="}],"size":7611,"noattachment":false,"key":"/@putout/plugin-destructuring/-/@putout/plugin-destructuring-2.1.1.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-destructuring_2.1.1_1780960618462_0.6993593339953399"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-destructuring [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-destructuring.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-destructuring \"npm\"\n\n> The **destructuring** assignment syntax is a **JavaScript** expression that makes it possible to unpack values from `arrays`, or `properties` from `objects`, into distinct `variables`.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to use **destructuring** on variable declarations.\n\n## Install\n\n```\nnpm i @putout/plugin-destructuring\n```\n\n## Rules\n\n- ✅ [apply-array](#apply-array);\n- ✅ [apply-object](#apply-object);\n- ✅ [convert-object-to-array](#convert-object-to-array);\n- ✅ [extract-properties](#extract-properties);\n- ✅ [remove-useless-object](#remove-useless-object);\n- ✅ [remove-useless-arguments](#remove-useless-arguments);\n- ✅ [remove-useless-variables](#remove-useless-variables);\n- ✅ [remove-useless-rename](#remove-useless-rename);\n- ✅ [split-nested](#split-nested);\n- ✅ [split-call](#split-call);\n- ✅ [merge-properties](#merge-properties);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"destructuring/apply-array\": \"on\",\n        \"destructuring/apply-object\": \"on\",\n        \"destructuring/convert-object-to-array\": \"on\",\n        \"destructuring/extract-properties\": \"on\",\n        \"destructuring/remove-useless-object\": \"on\",\n        \"destructuring/remove-useless-arguments\": \"on\",\n        \"destructuring/remove-useless-variables\": \"on\",\n        \"destructuring/remove-useless-rename\": \"on\",\n        \"destructuring/split-nested\": \"on\",\n        \"destructuring/split-call\": \"on\",\n        \"destructuring/merge-properties\": \"on\"\n    }\n}\n```\n\n## apply-array\n\n### ❌ Example of incorrect code\n\n```js\nconst first = array[0];\n```\n\n### ✅ Example of correct code\n\n```js\nconst [first] = array;\n```\n\n## apply-object\n\n### ❌ Example of incorrect code\n\n```js\nconst name = user.name;\n\nhello = world.hello;\n```\n\n### ✅ Example of correct code\n\n```js\nconst {name} = user;\n\n({hello} = world);\n```\n\n## remove-useless-object\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c9ed04b421d75ae39e58038fa6e14630/4c097e3173990ec7e5ebabbe2cedf8e952092ebf).\n\n### ❌ Example of incorrect code\n\n```js\nconst {maxElementsInOneLine} = {\n    options,\n};\n```\n\n### ✅ Example of correct code\n\n```js\nconst {maxElementsInOneLine} = options;\n```\n\n## remove-useless-rename\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/bff12ac912bec590fece55d63af467fc/0928cb7c8403d77497e9619503caa29ca6c1538c).\n\n### ❌ Example of incorrect code\n\n```js\nconst {\n    convert: convertFn = convertFile,\n} = overrides;\n\nconvertFn('hello');\n```\n\n### ✅ Example of correct code\n\n```js\nconst {\n    convert = convertFile,\n} = overrides;\n\nconvert('hello');\n```\n\n## convert-object-to-array\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a1d26daf8bb83ee3ea1c0b62a6ad3afd/cef9b4d27c9dbb0d413a935b0359a6fe9b50364f).\n\n### ❌ Example of incorrect code\n\n```js\nconst {0: a, 1: b} = c;\n```\n\n### ✅ Example of correct code\n\n```js\nconst [a, b] = c;\n```\n\n## split-nested\n\n> - Don't use nested destructuring on data that comes from any external data sources (such as `REST API`s, `GraphQL` endpoints or files).\n> - Don't use nested destructuring on function arguments that have long or complicated signatures.\n>\n> (c) [Destructuring in JavaScript: the not so good parts](https://goodguydaniel.com/blog/destructuring-not-so-good-parts)\n\n### ❌ Example of incorrect code\n\n```js\nconst {\n    a: {\n        b,\n    },\n    a: {\n        b: x,\n    },\n} = c;\n\nfunction f({a}) {\n    const {b} = a;\n    console.log(b);\n}\n```\n\n### ✅ Example of correct code\n\n```js\nconst {a} = c;\nconst {b, b: x} = a;\n\nfunction f({a}) {\n    const {b} = a;\n    console.log(b);\n}\n```\n\n## split-call\n\n### ❌ Example of incorrect code\n\n```js\nconsole.log('hello')({uid} = path.scope);\nconsole.log('hello')[uid] = path.scope;\n```\n\n### ✅ Example of correct code\n\n```js\nconsole.log('hello');\n({uid} = path.scope);\n\nconsole.log('hello');\n[uid] = path.scope;\n```\n\n## merge-properties\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/11c8cfa59f87e46238309b857448b9c5/688f10ad8fd7c0e4d9e9e0c74c399f1edb3ba29e).\n\n### ❌ Example of incorrect code\n\n```js\nconst {one} = require('numbers');\nconst {two} = require('numbers');\n\n({from} = data);\n({to} = data);\n({names} = data);\n```\n\n### ✅ Example of correct code\n\n```js\nconst {one, two} = require('numbers');\n\n({\n    from,\n    to,\n    names,\n} = data);\n```\n\n## remove-useless-arguments\n\n### ❌ Example of incorrect code\n\n```js\nonIfStatement({\n    push,\n    generate,\n    abc,\n    helloworld,\n});\n\nfunction onIfStatement({push}) {}\n```\n\n### ✅ Example of correct code\n\n```js\nonIfStatement({\n    push,\n});\n\nfunction onIfStatement({push}) {}\n```\n\n## remove-useless-variables\n\n### ❌ Example of incorrect code\n\n```js\nfunction hi(c) {\n    const {a, b} = c;\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction hi({a, b}) {}\n```\n\n## extract-properties\n\n### Equal Deep\n\n#### ❌ Example of incorrect code\n\n```js\nconst {replaceWith} = a.operate;\nconst {isIdentifier} = a.types;\n```\n\n#### ✅ Example of correct code\n\n```js\nconst {operator, types} = a;\n\nconst {replaceWith} = operator;\nconst {isIdentifier} = types;\n```\n\n### Not Equal Deep\n\n#### ❌ Example of incorrect code\n\n```js\nconst {replaceWith} = a;\nconst {isIdentifier} = a.types;\n```\n\n#### ✅ Example of correct code\n\n```js\nconst {replaceWith, types} = a;\nconst {isIdentifier} = types;\n```\n\n## License\n\nMIT\n","publish_time":1780960618621,"_cnpm_publish_time":1780960618621,"dist-tags":{"latest":"2.1.1"}}