{"_id":"@bdwain/eslint-plugin-better-mutation","_rev":"1-bd725fc8d5ff5db37f4e8c6ced222e1e","name":"@bdwain/eslint-plugin-better-mutation","dist-tags":{"latest":"1.3.2"},"versions":{"1.3.2":{"name":"@bdwain/eslint-plugin-better-mutation","version":"1.3.2","description":"ESLint rules for controlling where and how mutation is used.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sloops77/eslint-plugin-better-mutation.git"},"author":{"name":"Andres Olave","email":"andres@thinkingbytes.net","url":"github.com/sloops77"},"engines":{"node":">=10.0.0"},"scripts":{"init:ci":"rimraf reports && mkdir -p reports","lint":"xo","lint:ci":"xo --reporter junit > reports/lint-results.xml","test":"nyc ava","test:ci":"nyc --reporter=lcov ava --tap | tap-xunit > reports/test-results.xml"},"keywords":["eslint","plugin","eslint-plugin","eslintplugin","fp","FP","function","functional","programming","lodash","mutation","immutable","function","functions","method","methods"],"dependencies":{"create-eslint-index":"~1.0.0","eslint-ast-utils":"~1.1.0","import-modules":"~2.0.0","lodash":"~4.17.20"},"devDependencies":{"@ava/babel":"^1.0.1","ava":"~3.14.0","eslint":"~7.15.0","eslint-ava-rule-tester":"~4.0.0","inject-in-tag":"~1.1.1","nyc":"~15.1.0","pify":"~5.0.0","rimraf":"~3.0.2","tap-xunit":"~2.4.1","xo":"~0.35.0"},"peerDependencies":{"eslint":">=6"},"xo":{"esnext":true,"space":2},"ava":{"babel":true},"gitHead":"463127cf5edb39f5d938b38f00145e5a15f8b060","bugs":{"url":"https://github.com/sloops77/eslint-plugin-better-mutation/issues"},"homepage":"https://github.com/sloops77/eslint-plugin-better-mutation#readme","_id":"@bdwain/eslint-plugin-better-mutation@1.3.2","_nodeVersion":"14.16.0","_npmVersion":"7.10.0","dist":{"integrity":"sha512-MUAfAdihSzQZDc1/ZAbUAtvboWn5F9l603FZooP79EtpzCGJtKLesIHBmmxY3cc5qp1sF3OD76O03KZ+dlx+ig==","shasum":"faa9a4964cc3f87b5d924b765b4cee96833d9ab6","tarball":"https://registry.npmjs.org/@bdwain/eslint-plugin-better-mutation/-/eslint-plugin-better-mutation-1.3.2.tgz","fileCount":8,"unpackedSize":25483,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgj4ebCRA9TVsSAnZWagAAp1cP/2LKl9BLFdOcw6LWKWxn\n+iznOb7kpO7aMgGY8+OFgHi4x0dHUpL/Cmh5oCZ6MepprhVPhYBpdqzBe9sG\nZeQeUQ9LGX90mETCvAWMLXPa+qdni85cArO2Uh4CvhcECWw7RzymLFrDwiSL\nf8SxV102rUHQmsH8zTC5qoSdgEc4sS66ULq4uDDfgGprfqLjT/tZ+xynSi72\npyI87xvDxvlpXMEGpVPjXqCYwAODl79ZD5/LO0tm0LIxD/GttN2U5wbjoY/I\n+CnCxOiuEe+I/Sc75OpeKSyI+prQEN+PQNC/i0bCG6qQiPKJqUXEFMExObjk\niQPt9i7yAjgBBfslRKbFJ3jSvhXpscsrsR3j0MFKtooJfTSk18kNB2JUVpZL\nXTrRXNqYhNe3dfzMxZift9wjJVgeCAvq1bxrCRoJmsESr4CvOQCKd/tIMyhi\n6DrbbOiYJAnwG/A4Ls3OdgokMYJ30CKKIRbZDu5TrkIoj9xy4diJzejffQvF\niqrWFde/9qVsDubzHqrblbVUSJ9Nuznc7Ti6kZq2k3ktLKoCbfR3hm/BkHxK\no7IBaDmRRhlP8fdaZ4QtH8l4gpMuSQrw8pXgQMhqd7AUxPKDK7051iTn2Zvm\nfPfvfiRFKzGwBGw+t+5I2y9IK4Anf6Ebomxk+X1EijG6GAddHNAFskJYQevZ\n5PLm\r\n=56Pa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIAbcSSuR/YRBclKNJGjMyDPsaTvK9gwknDzuNIBS+PAIgGWlkgfJ+mZYvQzyWMPC/mH2CGdY1V1qs/4QgWm8JA7M="}]},"_npmUser":{"name":"bdwain","email":"bryandwain@gmail.com"},"directories":{},"maintainers":[{"name":"bdwain","email":"bryandwain@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-better-mutation_1.3.2_1620019098699_0.3209809620239157"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-03T05:18:18.649Z","1.3.2":"2021-05-03T05:18:18.889Z","modified":"2022-04-04T18:03:58.730Z"},"maintainers":[{"name":"bdwain","email":"bryandwain@gmail.com"}],"description":"ESLint rules for controlling where and how mutation is used.","homepage":"https://github.com/sloops77/eslint-plugin-better-mutation#readme","keywords":["eslint","plugin","eslint-plugin","eslintplugin","fp","FP","function","functional","programming","lodash","mutation","immutable","function","functions","method","methods"],"repository":{"type":"git","url":"git+https://github.com/sloops77/eslint-plugin-better-mutation.git"},"author":{"name":"Andres Olave","email":"andres@thinkingbytes.net","url":"github.com/sloops77"},"bugs":{"url":"https://github.com/sloops77/eslint-plugin-better-mutation/issues"},"license":"MIT","readme":"# eslint-plugin-better-mutation \n[![CircleCI](https://circleci.com/gh/sloops77/eslint-plugin-better-mutation.svg?style=svg)](https://circleci.com/gh/sloops77/eslint-plugin-better-mutation)\n[![codecov](https://codecov.io/gh/sloops77/eslint-plugin-better-mutation/branch/master/graph/badge.svg)](https://codecov.io/gh/sloops77/eslint-plugin-better-mutation)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)\n\nESLint rules so you and your team use immutable values when you should, and permits mutation when it's safe.\n\nPreventing unsafe mutation of **shared** variables prevents a huge class of bugs from ever appearing.\n\nThe plugin's goal is to prevent modification of **shared** variables, such as function parameters or globals whether via assignment, operators, functions or methods. \n\nLocally declared variables are permitted to use mutation, because in most circumstances this is safe.\n\nSee [WHY.](why.md)\n\n## What's safe?\nBlock scoped (`let`) or function scoped variables (`var`) can be reassigned safely. Even objects or arrays marked with `const` can have nested properties changed within the block scope they belong to. The same rules apply for mutating functions (e.g. `Object.assign()` and mutating methods `[].push()`\n\n```\nfunction foo() {\n  let i = 1; \n  i = 2;\n  \n  const o = { a: 0 };\n  o.a += 1;\n}\n\nmodule.exports = { foo }; // by default commonjs exports are configured to be safe\n``` \n\nAlso modification of parameters within reducer functions/methods is safe. The parameters of a reducer a safe because \nthe loop that the reducer executes limits the scope of the accumulator to the reducer function. \n\n``` \nfunction sum(numbers) {\n  return numbers.reduce((acc, val) => {\n    acc += val;  // this is safe!\n    return acc;    \n  }, 0);\n}\n\n``` \n\n## What's not safe?\nMutating variables of **shared** variables is unsafe. This means reassignment outside of the scope they are declared within whether its because they are globals, function parameters, or closed over variables can lead to undefined behaviour that is hard to debug and can cause race conditions. Instead of mutating always return a new value.\n\n```\ng = 2 // global reassignment is unsafe\n\nfunction foo(i) {\n   i += 1 // don't resassign function parameters\n}\n\nlet a = 1; \nfunction bar() { \n   a = 2; // don't reassign closed over vars\n}\n```\n\n## Install\n\n```\n$ npm install --save-dev eslint eslint-plugin-better-mutation\n```\n\n## Usage\n\nConfigure it in `.eslintrc`.\n\n<!-- EXAMPLE_CONFIGURATION:START -->\n```json\n{\n  \"name\": \"my-awesome-project\",\n  \"eslintConfig\": {\n    \"env\": {\n      \"es6\": true\n    },\n    \"plugins\": [\n      \"better-mutation\"\n    ],\n    \"rules\": {\n      \"better-mutation/no-mutating-functions\": \"error\",\n      \"better-mutation/no-mutating-methods\": \"error\",\n      \"better-mutation/no-mutation\": \"error\",\n    }\n  }\n}\n```\n<!-- EXAMPLE_CONFIGURATION:END -->\n\n## Rules\n\n<!-- RULES:START -->\n- [no-mutation](docs/rules/no-mutation.md) - Forbid the use of mutating operators on non-local variables.\n- [no-mutating-methods](docs/rules/no-mutating-methods.md) - Forbid the use of mutating methods on non-local variables such as push or _.remove.\n- [no-mutating-functions](docs/rules/no-mutating-functions.md) - Forbid the use of [`Object.assign() and lodash mutation methods`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) with a non-local variable as first argument.\n\n<!-- RULES:END -->\n\n## Recommended configuration\n\nThis plugin exports a [`recommended` configuration](index.js) that enforces good practices.\n\nTo enable this configuration, use the `extends` property in your `.eslintrc`.\n\n```json\n{\n  \"name\": \"my-awesome-project\",\n  \"eslintConfig\": {\n    \"plugins\": [\n      \"better-mutation\"\n    ],\n    \"extends\": \"plugin:better-mutation/recommended\"\n  }\n}\n```\n\nSee [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information about extending configuration files.\n\nMIT © [Andres Olave](https://github.com/sloops77)\n\nThanks to [Jeroen Engels](https://github.com/jfmengels) for providing the basis of this plugin. Checkout https://github.com/jfmengels/eslint-plugin-fp for a strict functional programming approach.\n","readmeFilename":"readme.md"}