{"name":"@putout/plugin-remove-useless-spread","version":"6.1.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@6.1.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-spread#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"241d217cc5d06237124aee7191218d5cdda79423","tarball":"http://registry-npm.ywwl.com/@putout/plugin-remove-useless-spread/download/@putout/plugin-remove-useless-spread-6.1.0.tgz","fileCount":6,"integrity":"sha512-x8u/fY8+5TIviW/h8ynXsXi4GmHd8Z30mOrVaUl9WrWM/eyi9uwj4Li08WWV0qjkJSA8VnyEiULSUv8W1IUw+Q==","signatures":[{"sig":"MEYCIQCH0/RmGYPTm4KWMRux8ByTWpEfd94/oQSLPwev2uL6TwIhAJ5axcEsHCT6derZ6GPHhTWbZiESL29xLq0joqdS3oW4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5189,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjigNmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpxKQ//VDvnxJJgmCQ3GV9q2/gBrbcxAa7Yg6TQT4xoyRVAl2cmzcan\r\nNgzXK9kloWpbIGo61dBGrr+bGlbiwJaI07Phw+NbgHNqWGtr6qEX5vYa50nG\r\ndPLCLmFS/cPmWkh0+PCFcn4UJPG1tgefz9rYvUgnsOXJe4deMz6sCkAEcEnq\r\n0b2AvatDjNOuPdwJJwvjlV2Ugbz6VQeHbwcMdALRninLKBbI6dfMfOhmi354\r\n7N8/yDXdzoq2welQfjAb/I82qjSYpfl+F/YTziwUaKbq/74PGvVDdQH5tr0P\r\n+H55ATWxty+3yNkjEpIhtTZ750E3ytZVlc+jEAbZZK6O1iQ4IZUyV19Rif7T\r\n9wqJDIICwM7UrQgOAsufHaQLdCvQFEeKQzpPgHDKj2br8OOj9lxFhBGdGYUC\r\nlnrGQp1ja9+AHrIFzoe/vn5QufwkWvIg/DHYhVlsYMuMBmUAkqQ+REgBA5Yx\r\nI/fEY4N8/Fmuw92DZFFUpp6xs64Igw/0RQLTCYNEAhAL2W6BhhkoRqvDlb21\r\nb24+Dc+zZrL2MozcL/O1tRyg7JrkVEvNah20HUmSR/c6YUoe2xnEduoQ8aE0\r\nvT9MEYVk1lONUiCqOsPn0nRXGw636IiGI2enGDXsi3Jib+hvvmJ32imrUIy1\r\nIBtzqDySpPIa9yv8CLcL4/TV4vtpzcr//Gc=\r\n=YukX\r\n-----END PGP SIGNATURE-----\r\n","size":2520,"noattachment":false,"key":"/@putout/plugin-remove-useless-spread/-/@putout/plugin-remove-useless-spread-6.1.0.tgz"},"main":"lib/remove-useless-spread.js","type":"commonjs","engines":{"node":">=16"},"gitHead":"95b62966bdcedfd849cc9e182a5c36576777d4a4","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,"commitType":"colon","repository":{"url":"git://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"8.3.0","description":"🐊Putout plugin adds ability to remove useless spread","directories":{},"_nodeVersion":"18.12.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.5.0","eslint":"^8.0.1","madrun":"^9.0.0","@putout/test":"^5.0.0","eslint-plugin-n":"^15.2.4"},"peerDependencies":{"putout":">=26"},"_npmOperationalInternal":{"tmp":"tmp/plugin-remove-useless-spread_6.1.0_1669989222567_0.057276079279260816","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":1669989222758,"_cnpm_publish_time":1669989222758,"dist-tags":{"latest":"13.1.1"}}