Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (24 sloc) 987 Bytes

Rule: thehelp/no-mutation

This rule is designed to push you towards more functional design, where methods don't modify the data passed into them. It makes programs far, far easier to reason about. Not allowed:

obj.x = 4; # invalid
module.exports = fn; # invalid = 'name'; # invalid


Yes, some kinds of mutation are required. Like module.exports, necessary to expose your code to other files via require(). To enable this without a tedious eslint-disable on every affected line, you can use exceptions:

  'thehelp/no-mutation': ['error', {
    exceptions: [{
      object: 'module',
      property: 'exports',
    }, {
      property: 'propTypes',
    }, {
      object: 'this',

Each exception can specify one or both of object and property. If only one is specified, everything which matches that single check will be excluded from the rule. All values are strings, and matched exactly.