Webpack: Eslint Airbnb config is not compatible with Vuex.

Created on 29 Aug 2017  路  4Comments  路  Source: vuejs-templates/webpack

no-param-reassign rule makes the Airbnb Eslint config incompatible with Vuex. In Vuex parameters mutation is required - this is how Vuex works.

So In order to fix this issue, the following override is needed:

"no-param-reassign": [
  "error",
  {
    "props": true,
    "ignorePropertyModificationsFor": [
      "state",
      "acc",
      "e",
      "ctx",
      "req",
      "request",
      "res",
      "response",
      "$scope"
    ]
  }
],

PS
All properties except state are in the ignorePropertyModificationsFor array by default.

enhancement help wanted

Most helpful comment

Sorry for asking here (I think this should be addressed in eslint repo), but I just installed the webpack template and this rule does not seem to be working at all. I've tried many different rules apart from the default ones and my parameter reassigns are always lint with error.

All the rules works, except for the 'no-param-reassign' one. Is this happening only with me?

All 4 comments

I used to disable this rule by adding eslint-disable for each vuex file, and your config seems better. I think we could use eslint conf's overrides field to make a finer restriction.

Sorry for asking here (I think this should be addressed in eslint repo), but I just installed the webpack template and this rule does not seem to be working at all. I've tried many different rules apart from the default ones and my parameter reassigns are always lint with error.

All the rules works, except for the 'no-param-reassign' one. Is this happening only with me?

This worked for me, after restarting dev environment.

I created a new .eslintrc.js file in my store folder and added them there

// airbnb eslint is incompatible with vuex, so we add:
"no-shadow": ["error", { "allow": ["state"] }],
"no-param-reassign": [
  "error",
  {
    "props": true,
    "ignorePropertyModificationsFor": [ // All properties except state are in the ignorePropertyModificationsFor array by default.
      "state",
      "acc",
      "e",
      "ctx",
      "req",
      "request",
      "res",
      "response",
      "$scope"
    ]
  }
],

This worked for me, after restarting dev environment.

Thanks for this comment. Errors went away in my IDE but project still wasn't working and I couldn't see why until I saw this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolas-t picture nicolas-t  路  4Comments

happy760690 picture happy760690  路  3Comments

connor11528 picture connor11528  路  3Comments

paulgeisler picture paulgeisler  路  3Comments

exarus picture exarus  路  3Comments