{"_id":"@putout/plugin-spread","_rev":"4160210","name":"@putout/plugin-spread","description":"🐊Putout plugin adds ability to remove useless spread","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"time":{"modified":"2026-03-01T20:37:49.000Z","created":"2025-12-01T09:49:03.013Z","3.0.0":"2026-02-16T22:13:20.086Z","2.0.0":"2026-01-21T17:24:16.325Z","1.2.0":"2025-12-01T14:19:12.061Z","1.1.0":"2025-12-01T12:34:18.106Z","1.0.0":"2025-12-01T09:49:03.013Z"},"users":{},"author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"versions":{"3.0.0":{"name":"@putout/plugin-spread","version":"3.0.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to remove useless spread","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"publishOnly":"madrun publishOnly","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","spread","useless"],"devDependencies":{"@putout/test":"^15.0.0","c8":"^10.0.0","eslint":"^10.0.0","eslint-plugin-putout":"^31.0.0","madrun":"^13.0.0"},"peerDependencies":{"putout":">=42"},"license":"MIT","engines":{"node":">=22"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-spread@3.0.0","gitHead":"efdde5b548c671ac4c40f147fab8d5e416f0d0c5","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"22.22.0","_npmVersion":"11.4.2","dist":{"shasum":"e739af9cbb3b02132922d9d3dff5947b9d2ecbdb","size":3988,"noattachment":false,"key":"/@putout/plugin-spread/-/@putout/plugin-spread-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-spread/download/@putout/plugin-spread-3.0.0.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-spread_3.0.0_1771279999938_0.3575791992538564"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-16T22:13:20.086Z","publish_time":1771280000086,"_source_registry_name":"default","_cnpm_publish_time":1771280000086},"2.0.0":{"name":"@putout/plugin-spread","version":"2.0.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to remove useless spread","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"publishOnly":"madrun publishOnly","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":{"eslint-plugin-putout":"^30.0.0"},"keywords":["putout","putout-plugin","plugin","spread","useless"],"devDependencies":{"@putout/eslint-flat":"^4.0.0","@putout/test":"^15.0.0","c8":"^10.0.0","eslint":"^10.0.0-alpha.0","eslint-plugin-n":"^17.0.0","madrun":"^12.0.0"},"peerDependencies":{"putout":">=41"},"license":"MIT","engines":{"node":">=22"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-spread@2.0.0","gitHead":"a7847484864c3d53013350b0a9c2e16c18b5713e","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"25.3.0","_npmVersion":"11.4.2","dist":{"shasum":"861abc24418aa627ffdfb83a6e021b4a6f2d48e8","size":4014,"noattachment":false,"key":"/@putout/plugin-spread/-/@putout/plugin-spread-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-spread/download/@putout/plugin-spread-2.0.0.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-spread_2.0.0_1769016256178_0.08247759464146953"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-01-21T17:24:16.325Z","publish_time":1769016256325,"_source_registry_name":"default","_cnpm_publish_time":1769016256325},"1.2.0":{"name":"@putout/plugin-spread","version":"1.2.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to remove useless spread","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"publishOnly":"madrun publishOnly","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":{"eslint-plugin-putout":"^29.0.0"},"keywords":["putout","putout-plugin","plugin","spread","useless"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/test":"^14.0.0","c8":"^10.0.0","eslint":"v10.0.0-alpha.0","eslint-plugin-n":"^17.0.0","madrun":"^11.0.0"},"peerDependencies":{"putout":">=40"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-spread@1.2.0","gitHead":"a59c8a790aeea305fa4a44fe4731252ec5b347ae","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"25.2.1","_npmVersion":"11.4.2","dist":{"shasum":"a2b0154676b20a13ff6029cbfbedbba3da70bf77","size":4004,"noattachment":false,"key":"/@putout/plugin-spread/-/@putout/plugin-spread-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-spread/download/@putout/plugin-spread-1.2.0.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-spread_1.2.0_1764598751858_0.4740251781454139"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-12-01T14:19:12.061Z","publish_time":1764598752061,"_source_registry_name":"default","_cnpm_publish_time":1764598752061},"1.1.0":{"name":"@putout/plugin-spread","version":"1.1.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to remove useless spread","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"publishOnly":"madrun publishOnly","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":{"eslint-plugin-putout":"^29.0.0"},"keywords":["putout","putout-plugin","plugin","spread","useless"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/test":"^14.0.0","c8":"^10.0.0","eslint":"v10.0.0-alpha.0","eslint-plugin-n":"^17.0.0","madrun":"^11.0.0"},"peerDependencies":{"putout":">=40"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-spread@1.1.0","gitHead":"c44094bbf521e8eff8429cb757b558af71e77885","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"25.2.1","_npmVersion":"11.4.2","dist":{"shasum":"84bdc743d7e4510739a1c44c7301a1ba94e24694","size":3375,"noattachment":false,"key":"/@putout/plugin-spread/-/@putout/plugin-spread-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-spread/download/@putout/plugin-spread-1.1.0.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-spread_1.1.0_1764592457825_0.6009230482226628"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-12-01T12:34:18.106Z","publish_time":1764592458106,"_source_registry_name":"default","_cnpm_publish_time":1764592458106},"1.0.0":{"name":"@putout/plugin-spread","version":"1.0.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to remove useless spread","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/putout.git"},"scripts":{"publishOnly":"madrun publishOnly","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":{"eslint-plugin-putout":"^29.0.0"},"keywords":["putout","putout-plugin","plugin","spread","useless"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/test":"^14.0.0","c8":"^10.0.0","eslint":"v10.0.0-alpha.0","eslint-plugin-n":"^17.0.0","madrun":"^11.0.0"},"peerDependencies":{"putout":">=40"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-spread@1.0.0","gitHead":"befe4bab18e2cd908ad78c802c6b561df522e3d5","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"25.2.1","_npmVersion":"11.4.2","dist":{"shasum":"7a9ca91b84d05cb72729ec6d045d38bd992ab9e0","size":3139,"noattachment":false,"key":"/@putout/plugin-spread/-/@putout/plugin-spread-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-spread/download/@putout/plugin-spread-1.0.0.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-spread_1.0.0_1764582542789_0.10938107413219433"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-12-01T09:49:03.013Z","publish_time":1764582543013,"_source_registry_name":"default","_cnpm_publish_time":1764582543013}},"readme":"# @putout/plugin-spread [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-spread.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-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 transform **spread** syntax.\n\n## Install\n\n```\nnpm i @putout/plugin-spread\n```\n\n## Rules\n\n- ✅ [convert-apply-to-spread](#convert-apply-to-spread);\n- ✅ [convert-convert-object-assign-to-merge-spread](#convert-object-assign-to-merge-spread);\n- ✅ [simplify-nested](#simplify-nested);\n- ✅ [remove-useless-array](#remove-useless-array);\n- ✅ [remove-useless-object](#remove-useless-object);\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"spread/convert-apply-to-spread\": \"on\",\n        \"spread/convert-object-assign-to-merge-spread\": \"on\",\n        \"spread/remove-useless-array\": \"on\",\n        \"spread/remove-useless-object\": \"on\",\n        \"spread/simplify-nested\": \"on\"\n    }\n}\n```\n\n## convert-object-assign-to-merge-spread\n\n> The [`Object.assign()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) method copies all enumerable own properties from one or more source objects to a target object and returns the modified target object.\n>\n> [**Spread**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) syntax (`...`) allows an object expression to be expanded in places where zero or more key-value pairs are expected.\n>\n> (c) MDN\n\nConvert `Object.assign()` to merge **spread** since it shorter but does (mostly) the same.\n\n### ❌ Example of incorrect code\n\n```js\nfunction merge(a) {\n    return Object.assign({}, a, {\n        hello: 'world',\n    });\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfunction merge(a) {\n    return {\n        ...a,\n        hello: 'world',\n    };\n}\n```\n\n### Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n???? **Putout** | [`spread/convert-object-assign-to-merge-spread`](https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#convert-object-assign-to-merge-spread) | ✅\n⏣ **ESLint** | [`prefer-object-spread`](https://eslint.org/docs/rules/prefer-object-spread) | ✅\n\n## remove-useless-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## remove-useless-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## convert-apply-to-spread\n\n> Spread syntax (`...`) allows an array expression to be expanded in places where zero or more arguments are expected.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)\n\n### ❌ Example of incorrect code\n\n```js\nconsole.apply(null, arguments);\n```\n\n### ✅ Example of correct code\n\n```js\nconsole.log(...arguments);\n```\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-spread#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"license":"MIT"}