{"_id":"@putout/plugin-assignment","_rev":"4160169","name":"@putout/plugin-assignment","description":"🐊Putout plugin adds ability to transform code related to assignment","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"time":{"modified":"2026-03-01T20:37:41.000Z","created":"2025-03-24T18:13:10.572Z","2.1.0":"2025-07-20T11:05:51.266Z","2.0.0":"2025-05-31T21:31:17.016Z","1.0.2":"2025-03-24T20:18:25.164Z","1.0.1":"2025-03-24T18:13:10.572Z"},"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":{"2.1.0":{"name":"@putout/plugin-assignment","version":"2.1.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to transform code related to assignment","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-assignment#readme","main":"lib/index.js","exports":{".":"./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","assignment"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/plugin-declare":"*","@putout/plugin-declare-before-reference":"*","@putout/plugin-putout":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-typescript":"*","@putout/test":"^13.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^28.0.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=40"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-assignment@2.1.0","gitHead":"7389d0f51cd5b1c78259adbb38d34af71beb6883","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"shasum":"3e3ec1932d7de4599dbf714f37a3487ae677586b","size":4196,"noattachment":false,"key":"/@putout/plugin-assignment/-/@putout/plugin-assignment-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-assignment/download/@putout/plugin-assignment-2.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-assignment_2.1.0_1753009551100_0.09848086010696977"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-20T11:05:51.266Z","publish_time":1753009551266,"_source_registry_name":"default","_cnpm_publish_time":1753009551266},"2.0.0":{"name":"@putout/plugin-assignment","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 transform code related to assignment","homepage":"https://github.com/coderaiser/putout/tree/v38.5.7/packages/plugin-assignment#readme","main":"lib/index.js","exports":{".":"./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","assignment"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/plugin-declare":"*","@putout/plugin-declare-before-reference":"*","@putout/plugin-putout":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-typescript":"*","@putout/test":"^13.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^27.0.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=40"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-assignment@2.0.0","gitHead":"3cee05e2800042c92c5aa54efe72677f19dd8652","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"20.19.0","_npmVersion":"11.1.0","dist":{"shasum":"33cf0fbfe597451789fdaf46a9075bc3a80e537c","size":4142,"noattachment":false,"key":"/@putout/plugin-assignment/-/@putout/plugin-assignment-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-assignment/download/@putout/plugin-assignment-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-assignment_2.0.0_1748727076827_0.05436612550208553"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-05-31T21:31:17.016Z","publish_time":1748727077016,"_source_registry_name":"default","_cnpm_publish_time":1748727077016},"1.0.2":{"name":"@putout/plugin-assignment","version":"1.0.2","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to transform code related to assignment","homepage":"https://github.com/coderaiser/putout/tree/v38.5.7/packages/plugin-assignment#readme","main":"lib/index.js","exports":{".":"./lib/index.js","./strict-mode":"./lib/strict-mode/index.js","./convert-esm-to-commonjs":"./lib/convert-esm-to-commonjs/index.js","./convert-commonjs-to-esm":"./lib/convert-commonjs-to-esm.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","assignment"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/plugin-declare":"*","@putout/plugin-declare-before-reference":"*","@putout/plugin-putout":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-typescript":"*","@putout/test":"^13.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^26.0.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=39"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-assignment@1.0.2","gitHead":"7a11f08d82efa2ce0dda434aee74185fbdf85dbf","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"22.14.0","_npmVersion":"11.1.0","dist":{"shasum":"5e0dd7f374425398a171da355392d919436bb504","size":4186,"noattachment":false,"key":"/@putout/plugin-assignment/-/@putout/plugin-assignment-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-assignment/download/@putout/plugin-assignment-1.0.2.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-assignment_1.0.2_1742847504966_0.5270787759867486"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-24T20:18:25.164Z","publish_time":1742847505164,"_source_registry_name":"default","_cnpm_publish_time":1742847505164},"1.0.1":{"name":"@putout/plugin-assignment","version":"1.0.1","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to transform code related to assignment","homepage":"https://github.com/coderaiser/putout/tree/v38.5.7/packages/plugin-assignment#readme","main":"lib/index.js","exports":{".":"./lib/index.js","./strict-mode":"./lib/strict-mode/index.js","./convert-esm-to-commonjs":"./lib/convert-esm-to-commonjs/index.js","./convert-commonjs-to-esm":"./lib/convert-commonjs-to-esm.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","assignment"],"devDependencies":{"@putout/eslint-flat":"^3.0.0","@putout/plugin-declare":"*","@putout/plugin-declare-before-reference":"*","@putout/plugin-putout":"*","@putout/plugin-reuse-duplicate-init":"*","@putout/plugin-typescript":"*","@putout/test":"^13.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^26.0.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=39"},"license":"MIT","engines":{"node":">=20"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-assignment@1.0.1","gitHead":"a5615c6735219a7518a1bfd7c3adda98f87e9138","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"22.14.0","_npmVersion":"11.1.0","dist":{"shasum":"be878027a8007304c91f64226f7d286b69b5a053","size":4203,"noattachment":false,"key":"/@putout/plugin-assignment/-/@putout/plugin-assignment-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@putout/plugin-assignment/download/@putout/plugin-assignment-1.0.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-assignment_1.0.1_1742839990341_0.3712902052865499"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-24T18:13:10.572Z","publish_time":1742839990572,"_source_registry_name":"default","_cnpm_publish_time":1742839990572}},"readme":"# @putout/plugin-assignment [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-assignment.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-assignment \"npm\"\n\n> The [**assignment operator**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment) (`=`) is used to assign a value to a variable. The assignment operation evaluates to the assigned value. Chaining the assignment operator is possible in order to assign a single value to multiple variables.\n\n????[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new **Node.js** API and apply best practices.\n\n## Install\n\n```\nnpm i putout @putout/plugin-assignment -D\n```\n\n## Rules\n\n- ✅ [convert-to-arrow-function](#convert-to-arrow-function);\n- ✅ [convert-to-comparison](#convert-to-comparison);\n- ✅ [convert-to-declaration](#convert-to-declaration);\n- ✅ [simplify](#simplify);\n- ✅ [split](#split);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"assignment/convert-to-arrow-function\": \"on\",\n        \"assignment/convert-to-comparison\": \"on\",\n        \"assignment/convert-to-declaration\": \"on\",\n        \"assignment/simplify\": \"on\",\n        \"assignment/split\": \"on\"\n    }\n}\n```\n\n## convert-to-arrow-function\n\n> An [**arrow function expression**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) is a compact alternative to a **function expression**.\n>\n> (c) MDN\n\nRule adds ability to convert **assignment** to **arrow** function.\n\n### ❌ Example of incorrect code\n\n```js\nconst createRegExp = a = RegExp(a, 'g');\n```\n\n### ✅ Example of correct code\n\n```js\nconst createRegExp = (a) => RegExp(a, 'g');\n```\n\n## convert-to-comparison]\n\n> You should almost never have an `if...else` with an assignment like `a = b` as a condition.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)\n\n### ❌ Example of incorrect code\n\n```js\nif (a = b) {}\n```\n\n### ✅ Example of correct code\n\n```js\nif (a === b) {}\n```\n\n## convert-to-declaration\n\n> The `const` declaration declares block-scoped local variables. The value of a constant can't be changed through reassignment using the assignment operator, but if a constant is an object, its properties can be added, updated, or removed.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const)\n\nCheckout in ????[**Putout Editor**](https://putout.cloudcmd.io/#/gist/857e6bdc83dc2ee947b2945f6600d417/34d1c3852d85225da7eabdf9b91c138b7533c60b).\n\n## ❌ Example of incorrect code\n\n```js\na = 5;\n```\n\n## ✅ Example of correct code\n\n```js\nconst a = 5;\n```\n\n## simplify\n\n### ❌ Example of incorrect code\n\n```js\nconst {a} = {\n    a: 5,\n};\n\nconst [b] = [5];\nconst c = (() => 7)();\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = 5;\nconst b = 5;\nconst c = 7;\n```\n\n## split\n\nRule adds ability to find and split variable declarations because (re)moving a line is simpler and less error prone then changing coma (`=`) to colon (`;`).\n\nFor the same reason, **diff** of changed declarations are more comfortable to read. Checkout in ????[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fee33133e2313c3a741193570e307a58/f8fae66c93acc546194df49fff2a5fc13de8434c).\n\n## ❌ Example of incorrect code\n\n```js\na = b = c = 1;\n```\n\n## ✅ Example of correct code\n\n```js\na = 1;\nb = a;\nc = a;\n```\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-assignment#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"license":"MIT"}