ESLint rules for better mutation rules
$ npm install --save-dev eslint eslint-plugin-better-mutation
Configure it in .eslintrc
.
{
"name": "my-awesome-project",
"eslintConfig": {
"env": {
"es6": true
},
"plugins": [
"better-mutation"
],
"rules": {
"better-mutation/no-mutating-functions": "error",
"better-mutation/no-mutating-methods": "error",
"better-mutation/no-mutation": "error",
}
}
}
- no-mutating-functions - Forbid the use of
Object.assign() and lodash mutation methods
with a non-local variable as first argument. - no-mutating-methods - Forbid the use of mutating methods on non-local variables.
- no-mutation - Forbid the use of mutating operators on non-local variables.
This plugin exports a recommended
configuration that enforces good practices.
To enable this configuration, use the extends
property in your .eslintrc
.
{
"name": "my-awesome-project",
"eslintConfig": {
"plugins": [
"better-mutation"
],
"extends": "plugin:better-mutation/recommended"
}
}
See ESLint documentation for more information about extending configuration files.
MIT © Andres Olave
Thanks to Jeroen Engels. Checkout https://github.com/jfmengels/eslint-plugin-fp for a real functional programming eslint