{"name":"@putout/plugin-remove-useless-spread","version":"5.2.0","keywords":["putout","putout-plugin","plugin","spread","useless"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-remove-useless-spread@5.2.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-spread","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"743937443cbf06283c67eaf9bfcb3700fbae6c39","tarball":"http://registry-npm.ywwl.com/@putout/plugin-remove-useless-spread/download/@putout/plugin-remove-useless-spread-5.2.0.tgz","fileCount":6,"integrity":"sha512-RUDjdI8M7B8TMei1zTohZpplodXIQRhumZVhxyfuif3c4/28C+DfYLQEOEMhwTSAxRxyn/NzCbGPHrvT1IL1iQ==","signatures":[{"sig":"MEQCIGRbc1/+MRmeq95Ct/fpNcu0OZgG9rA1tA2gUv5x9llqAiAQRBzt7A3JhmnEfr7cihlTUl79kIOWiq3j7u8VlGb6cg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4013,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmsyqCRA9TVsSAnZWagAAmwQP/iWBKYQbbMLNymSMJ996\nLT95JaIEd+ujFAuLe8v7E2cRSO4MFY1IAAb2OjTgUJLBITPx/jPA4hHQ3zSX\nqu2iySZUcyB+/iADtruXadIzz/Rig5xPsZNSFALuWyPMa1DkVGX4Vxzh0nA5\n932NYviJ7AOZGpZFnYialq/Zj3iLV1f4V6/WqHz36K0LOASjq5sTbvuv1T3j\nwaa6ZpwlWyTrVlmcCpb9QcEWQpiKnovbXm0iXVwoGLgqpRCM6UAcVaHBSczL\nI0FolBai7abOy/tWlPS0lMa5gLA0pT/QGchEG+SdHsjcMo1oaw6Z313bGkvg\nbyFUagGcN8nRs1VMrZlj8LdCnLAaRPDnc8OUZSUoDBqnmxBISHk8yhHjibEG\npL1ESGE0jUBOqOqZxTAdBYRFr4vgtuiEfn+NLXF712l+JTUQHXjYu/IRAPzG\nkuil+Gs1uzF+NMIOLNY7mi8eDik+JvtHBKZSoM7yScGBFzjKeFu/iknkdhqf\nWS/jkRRb8ej5B55h2Rtqn1eDEihGpOdbM/dIf3GQeHT8xBkHvVRia0nAXaZf\nlphViqpadDthArd9IBfA3skugJmIFSyTvl5mEgHnLz5zIapqmICVw7h7PSe8\n3upeQWTFLyF2aUJOXBQwRc1upoqG96R3mvEZX39FOS5kwvoJqvSHPscus34a\nlWQ+\r\n=6tHi\r\n-----END PGP SIGNATURE-----\r\n","size":1970,"noattachment":false,"key":"/@putout/plugin-remove-useless-spread/-/@putout/plugin-remove-useless-spread-5.2.0.tgz"},"main":"lib/remove-useless-spread.js","engines":{"node":">=14"},"gitHead":"dcfbe33e2b1cc559a0555cd61af06c748a48d70f","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test","publishOnly":"madrun publishOnly"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"8.1.0","description":"putout plugin adds ability to remove useless spread","directories":{},"_nodeVersion":"17.1.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.5.0","eslint":"^8.0.1","madrun":"^8.0.1","@putout/test":"^3.0.0","eslint-plugin-node":"^11.0.0"},"peerDependencies":{"putout":">=16"},"_npmOperationalInternal":{"tmp":"tmp/plugin-remove-useless-spread_5.2.0_1637534890079_0.7394403415814552","host":"s3://npm-registry-packages"},"readme":"# @putout/plugin-remove-useless-spread [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-remove-useless-spread.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-remove-useless-spread \"npm\"\n\n> **Spread** syntax can be used when all elements from an object or array need to be included in a list of some kind.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to remove useless **spread** syntax.\n\n## Install\n\n```\nnpm i @putout/plugin-remove-useless-spread\n```\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"remove-useless-spread/array\": \"on\",\n        \"remove-useless-spread/object\": \"on\",\n        \"remove-useless-spread/nested\": \"on\"\n    }\n}\n```\n\n## array\n\nThe thing is `[...b]` can be used for:\n\n- copying an array;\n- converting different value type like `string` to an `array`.\n\nSo better to be more concrete and use `slice` for copying and `Array()`/`Array.from()` for converting to decrease cognitive load.\nAlso sometimes there is no need on any of this operations, and we can drop `spread`.\n\n### ❌ Example of incorrect code\n\n```js\nfor (const a of [...b]) {}\n\nconst places = [...getPlaces()];\n```\n\n### ✅ Example of correct code\n\n```js\nfor (const a of b) {}\n\nconst places = getPlaces();\n\n// Array constructor creates sparse array\n[...Array(5)].map(Number);\n```\n\n## object\n\n### ❌ Example of incorrect code\n\n```js\nconst a = {\n    ...fn(),\n};\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = fn();\n```\n\n## nested\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/60e5a99112affb8a629347e5bf04aedf/38b33f3b5b133897b346a018462c431824e64bb8).\n\n### ❌ Example of incorrect code\n\n```js\n[\n    ...[\n        ...a,\n        ...b,\n    ],\n    ...x,\n];\n```\n\n### ✅ Example of correct code\n\n```js\n[\n    ...a,\n    ...b,\n    ...x,\n];\n```\n\n## License\n\nMIT\n","publish_time":1637534890254,"_cnpm_publish_time":1637534890254,"dist-tags":{"latest":"13.1.1"}}