2

I've got two variables in my webpack config which are required but are throwing linting errors.

Is there a way add exceptions for a specific variable?

I want to ignore path and persistentPlugins

current .eslintrc file looks as follows:

{
  "parser": "babel-eslint",
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  },
  "globals": {
    "React": false,
    "react": false,
  },
  "plugins": [
    "react"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ],
  "rules": {
    "no-console": 0,
    "no-underscore-dangle": 1,
    "quotes": [2, "single"],
    "react/no-danger": "off",
  }
}
Stretch0
  • 8,362
  • 13
  • 71
  • 133

1 Answers1

1

Assuming that it's the no-undef rule that's raising the error, specify them as globals:

...
"globals": {
  "path": true,
  "persistentPlugins": true,
  "React": false,
  "react": false,
},
...

Alternatively, you could disable the error inline in the webpack config:

/*global path, persistentPlugins*/

For other errors, there is a question here on disabling them inline.

Community
  • 1
  • 1
cartant
  • 57,105
  • 17
  • 163
  • 197
  • I believe it is the "no-unused-vars" rule as I am getting error: ` 3:8 error 'path' is defined but never used no-unused-vars` and when I turn that rule of it passes. Do I need to specify a case for that rule? – Stretch0 Aug 09 '16 at 04:01
  • If it's not used, you could remove it. However, if you just want the error to go away, you can [disable specific eslint errors inline](http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments): `/*eslint-disable no-unused-vars*/`. – cartant Aug 09 '16 at 04:04