{"_id":"@revved/eslint-plugin-immutable","_rev":"29-2560e6564a6d63c0b6e78d5ed6dd205f","name":"@revved/eslint-plugin-immutable","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@revved/eslint-plugin-immutable","version":"1.0.0","description":"ESLint plugin to disable all mutation in JavaScript.","main":"index.js","scripts":{"test":"mocha --recursive -s 15 test/","test-coverage":"istanbul cover _mocha -- --recursive","open-coverage":"open coverage/lcov-report/index.html"},"repository":{"type":"git","url":"git+https://github.com/jhusain/eslint-plugin-immutable.git"},"keywords":["eslint","immutability"],"devDependencies":{"eslint":"2.11.0","istanbul":"0.4.3","mocha":"2.5.3"},"author":{"name":"Jafar Husain"},"license":"Apache-2.0","bugs":{"url":"https://github.com/jhusain/eslint-plugin-immutable/issues"},"homepage":"https://github.com/jhusain/eslint-plugin-immutable#readme","gitHead":"2438a552582033f99297ec113765035b0efc3694","_id":"@revved/eslint-plugin-immutable@1.0.0","_nodeVersion":"10.14.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-NFe5Y9tK1ZFcgUZFL2pXc1n3ID1zlwWnfMOX0EpXH8ZpfgcHB8+1mSud+wOQr9psT7v8lCNuoej2qapAWE9oIA==","shasum":"d715ea70afdef0732b4d64b8e6283fe30ed54cc2","tarball":"https://registry.npmjs.org/@revved/eslint-plugin-immutable/-/eslint-plugin-immutable-1.0.0.tgz","fileCount":8,"unpackedSize":22505,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdUk/ICRA9TVsSAnZWagAAg8IP/2bOpm3JePV5JBhzZMz7\nXpon8vIwqUgNGBJdKxUwQx2MHbTFtHlMMvE9WRV0OtxbRBHkq6BwTbcs1PBY\n0L4hFTeEOFUA/zHmseHBRhFLY+BAZ/g59iGnjshL0hRAE/XVQvhutjoKhkeC\nA1BKA2dESSMsdw8c3bbcjEjoFAeioUJB6ovCDddNxFEhRuio0TMB1uhT9kpu\njahviMALBzfrPifJxHYYeNrPyzR3IzCAo5Uj0ESi30YUtORQsCb24ZqusWX5\n/iHJZTeFv0iAAGqIDoCUqKBwgGAyFHBhckVOjwwXH5reYWZyQVwLl9XNzE2m\nvmwsXg2CKYTO0N+FIm7TKGCjmxTylhhIglNs/JEN2hWIPGy9jxtkEeUVuDvr\nRkXf2eanWcVviRdCd3OvKdOpvOwhuaObGvR/s5Zwb1QEzZ35wxK3nbQAozFD\niNqO3Kl0VfGjt6+b4iOBwADT4lhsKc6o2t3/hRaJHW9sxcUuLq9ryo+mJhBz\nIbKm4PojxzwwRLRhDHEFJmffGB0/m/Ap9gGcPgCTS9GhJooWbITveZvEpNst\njI8CdXfyVynEoBRU+GdkPOondS1pv+RVVS0z+t8muffEXjCVpowluPm973e2\nsEya9FiHfjcbRHewGLShC+k0kGCejG3EfL5dFiy1dqTrcrEQZVJaFH/k8ne/\nNhth\r\n=E23W\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCwj+XhzM41akDVORdnbI/GSDZ2lKbqLXn+26n0bEgJSQIgfbbdfWVdNxFRnCWCSGdW1ORgsYaICdxpruOKag7tDwY="}]},"maintainers":[{"name":"addisonk","email":"addisonkillebrew@gmail.com"},{"name":"mfrr1118","email":"manuel@waitrapp.com"}],"_npmUser":{"name":"mfrr1118","email":"manuel@waitrapp.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-immutable_1.0.0_1565675462974_0.6799621275159857"},"_hasShrinkwrap":false},"1.0.1":{"name":"@revved/eslint-plugin-immutable","version":"1.0.1","description":"ESLint plugin to disable all mutation in JavaScript.","main":"index.js","scripts":{"test":"mocha --recursive -s 15 test/","test-coverage":"istanbul cover _mocha -- --recursive","open-coverage":"open coverage/lcov-report/index.html"},"repository":{"type":"git","url":"git+https://github.com/jhusain/eslint-plugin-immutable.git"},"keywords":["eslint","immutability"],"devDependencies":{"eslint":"2.11.0","istanbul":"0.4.3","mocha":"2.5.3"},"author":{"name":"Jafar Husain"},"license":"Apache-2.0","bugs":{"url":"https://github.com/jhusain/eslint-plugin-immutable/issues"},"homepage":"https://github.com/jhusain/eslint-plugin-immutable#readme","gitHead":"717c1e9169b615b7dc1f632895378fddbc216c43","_id":"@revved/eslint-plugin-immutable@1.0.1","_nodeVersion":"10.14.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-vEJTdOpe7S0YCiejDjm6KCgpq43jhajDSOjaXRYd5AyFA3cc6ou2WUtWTEEIcZCm9awVL3kav4ZHCH0Bb66kWw==","shasum":"8f34ca388d5016a8f314014f921e1ba358006205","tarball":"https://registry.npmjs.org/@revved/eslint-plugin-immutable/-/eslint-plugin-immutable-1.0.1.tgz","fileCount":8,"unpackedSize":22718,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZvhaCRA9TVsSAnZWagAALb8P/iaeFGScVEPlTtb8dKmP\nZuZwoP1SyjC2uU2MKCex4asiNvGXolOpJjiIVbKliyP9Xgv80osYIlnf+Bjb\n4P6eUclDcFn40MWLxXQUNeaqqp0sxfh+v/Yq4UbRI77bklaC3aRd2DyCe0C0\nGb+YfBqpraMCfWiAczyqASIn9oxS5lLUGcRoETLdr24irNB5xRfyYdTJFh8H\nOswd4asCip1evnDpnv2yuL2azXhCT86TEK00EakYuHD4yMeg3DyCKQlM4Je/\nIX3GTX9NSXJVXgEmzhXstjDfqebXPix1MoYMcdnXQ2POKJyCWyOmOS7PbXtd\nS5Zt2J+H1L6T2+h4FBtFq8gP4fVTyfHqXYhI+G71yU5CGOD7sc0LZMN65wMv\nFBcnvXie2SdKU2654YmlSfiuxztUMdzEldmazzAwlXkrU1vqP0VxH5YnzsyM\n62axiV/pEbZipCqA7kwtp1CPZMXhf/JwKLNazKHJ5oH6Iyb0aZPtvD96l1vg\n/IRiCREW3Hf4MH0BTowrdMsRlDXqp/NEj5zHgB510l251inNj2qUab45DxqZ\nzX5KzxVGJ3RxPWi48VUyzhoRWJMl5T/cROMCqWv937y6gVqbXKwJagUYO5oc\nMr7AX/0d0Z/L0wlO9DtcPZr426YVJ0alI02/Hq9ta79V1ITI5Q5NV9DblF2p\nLrEK\r\n=UcET\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqe12tuMy+goxujZ1kpq6DgA5X7psd5L4hbSRZN6TkfAIhAP9Kn3HYX5noBVIk8BpQ8+1Ez+JowM70C62QbZ8X3Tq0"}]},"maintainers":[{"name":"addisonk","email":"addisonkillebrew@gmail.com"},{"name":"mfrr1118","email":"manuel@waitrapp.com"}],"_npmUser":{"name":"mfrr1118","email":"manuel@waitrapp.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-immutable_1.0.1_1567029337672_0.46310011466555157"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-13T05:51:02.740Z","1.0.0":"2019-08-13T05:51:03.180Z","modified":"2024-02-02T19:40:29.237Z","1.0.1":"2019-08-28T21:55:37.792Z"},"maintainers":[{"email":"mfrr@me.com","name":"mfrr1118"},{"email":"addisonkillebrew@gmail.com","name":"addisonk"}],"description":"ESLint plugin to disable all mutation in JavaScript.","homepage":"https://github.com/jhusain/eslint-plugin-immutable#readme","keywords":["eslint","immutability"],"repository":{"type":"git","url":"git+https://github.com/jhusain/eslint-plugin-immutable.git"},"author":{"name":"Jafar Husain"},"bugs":{"url":"https://github.com/jhusain/eslint-plugin-immutable/issues"},"license":"Apache-2.0","readme":"# eslint-plugin-immutable\n\nThis is a fork of \nhttps://github.com/jhusain/eslint-plugin-immutable.\nThe purpose of the this fork was to be able to pusblish its \nlatest version to npm.\nThis is an ESLint plugin to disable all mutation in JavaScript. Think this is a bit too restrictive? Well if you're using Redux and React, there isn't much reason for your code to be mutating *anything*. Redux maintains a mutable pointer to your immutable application state, and React manages your DOM state. Your components should be stateless functions, translating data into Virtual DOM objects whenever Redux emits a new state. These ESLint rules explicitly prohibit mutation, effectively forcing you to write code very similar to [Elm](http://elm-lang.org/) in React.\n\n## Installing\n\n`npm install eslint-plugin-immutable --save-dev`\n\n## ESLint Rules\nThere are three rules in the plugin:\n\n### no-let\n\nThere's no reason to use `let` in a Redux/React application, because all your state is managed by either Redux or React. Use `const` instead, and avoid state bugs altogether.\n\n```JavaScript\nlet x = 5; // <- Unexpected let or var, use const.\n```\n\nWhat about `for` loops? Loops can be replaced with the Array methods like `map`, `filter`, and so on. If you find the built-in JS Array methods lacking, use [lodash](https://github.com/lodash/lodash).\n\n```JavaScript\nconst SearchResults =\n  ({ results }) =>\n    <ul>{\n      results.map(result => <li>{ result }</li>) // <- Who needs let?\n    }</ul>;\n```\n\n### no-this\n\nThanks to libraries like [recompose](https://github.com/acdlite/recompose) and Redux's [React Container components](http://redux.js.org/docs/basics/UsageWithReact.html), there's not much reason to build Components using `React.createClass` or ES6 classes anymore. The `no-this` rule makes this explicit.\n\n```JavaScript\nconst Message = React.createClass({\n  render: function() {\n    return <div>{ this.props.message }</div>; // <- no this allowed\n  }\n})\n```\n\nInstead of creating classes, you should use React 0.14's [Stateless Functional Components](https://medium.com/@joshblack/stateless-components-in-react-0-14-f9798f8b992d#.t5z2fdit6) and save yourself some keystrokes:\n\n```JavaScript\nconst Message = ({message}) => <div>{ message }</div>;\n```\n\nWhat about lifecycle methods like `shouldComponentUpdate`? We can use the [recompose](https://github.com/acdlite/recompose) library to apply these optimizations to your Stateless Functional Components. The [recompose](https://github.com/acdlite/recompose) library relies on the fact that your Redux state is immutable to efficiently implement shouldComponentUpdate for you.\n\n```JavaScript\nimport { pure, onlyUpdateForKeys } from 'recompose';\n\nconst Message = ({message}) => <div>{ message }</div>;\n\n// Optimized version of same component, using shallow comparison of props\n// Same effect as React's PureRenderMixin\nconst OptimizedMessage = pure(Message);\n\n// Even more optimized: only updates if specific prop keys have changed\nconst HyperOptimizedMessage = onlyUpdateForKeys(['message'], Message);\n```\n\n### no-mutation\n\nYou might think that prohibiting the use of `let` and `var` would eliminate mutation from your JavaScript code. **Wrong.** Turns out that there's a pretty big loophole in `const`...\n\n```JavaScript\nconst point = { x: 23, y: 44 };\npoint.x = 99; // This is legal\n```\n\nThis is why the `no-mutation` rule exists. This rule prevents you from assigning a value to the result of a member expression.\n\n```JavaScript\nconst point = { x: 23, y: 44 };\npoint.x = 99; // <- No object mutation allowed.\n```\n\nThis rule is just as effective as using Object.freeze() to prevent mutations in your Redux reducers. However this rule has **no run-time cost.** A good alternative to object mutation is to use the object spread syntax coming in ES2016.\n\n```JavaScript\nconst point = { x: 23, y: 44 };\nconst transformedPoint = { ...point, x: 99 };\n```\n\nYou can enable this syntax using the [syntax-object-rest-spread](https://babeljs.io/docs/plugins/syntax-object-rest-spread/) [Babel](https://babeljs.io/) plug-in.\n\n## Supplementary ESLint Rules to Enable\n\nThe rules in this package alone can not eliminate mutation in your JavaScript programs. To go the distance I suggest you also enable the following built-in ESLint rules:\n\n* no-var (self-explanatory)\n* no-undef (prevents assigning to global variables that haven't been declared)\n* no-param-reassign (prevents assigning to variables introduced as function parameters)\n\n## Sample Configuration File\n\nHere's a sample ESLint configuration file that activates these rules:\n\n```\n{\n    \"extends\": \"airbnb\",\n    \"plugins\": [\n        \"immutable\"\n    ],\n    \"rules\": {\n    \t\"immutable/no-let\": 2,\n    \t\"immutable/no-this\": 2,\n    \t\"immutable/no-mutation\": 2\n    }\n}\n```\n\nSpecial Thanks to [cerealbox](https://github.com/cerealbox) who paired with me on this.\n","readmeFilename":"README.md"}