Lints your code for modifying function arguments.
function BadCode(someObject) {
someObject.bad = 'do not mutate objects passed by reference'
}
yarn add --dev @exodus/eslint-plugin-mutable
// eslintrc.js
module.exports = {
plugins: ['@exodus/eslint-plugin-mutable'],
...
}
// eslintrc.js
module.exports = {
...
plugins: ['@exodus/eslint-plugin-mutable'],
rules: {
'@exodus/mutable/no-param-reassign-prop-only': 'error',
},
}
- Detects and reports assignment and modification of objects passed as argument to a function
Full Example
// eslintrc.js
module.exports = {
...
plugins: ['@exodus/eslint-plugin-mutable'],
rules: {
'@exodus/mutable/no-param-reassign-prop-only': 'error',
},
}