简体   繁体   中英

ESLint Configuration in WebStorm error

I am trying to get ESLint work in WebStorm IDE. I am furnishing my config file and the error.

Error

Error: /usr/local/lib/node_modules/eslint-config-airbnb/rules/react.js: Configuration for rule "react/jsx-boolean-value" is invalid: Value "never,[object Object]" should NOT have more than 1 items. Referenced from: /usr/local/lib/node_modules/eslint-config-airbnb/index.js Referenced from: /Users/xxx/WebstormProjects/xx-xx-ui/xx/code/.eslintrc.js at validateRuleOptions (/usr/local/lib/node_modules/eslint/lib/config/config-validator.js:113:15)

.eslintrc.js

module.exports = {
    "extends": "airbnb",
    "rules": {
      "import/extensions": 1,
      "import/first": 1,
      "import/prefer-default-export": 1,
      "max-len": 1,
      "no-case-declarations": 1,
      "no-console": 1,
      "no-empty": 0,
      "no-fallthrough": 1,
      "no-mixed-spaces-and-tabs": 1,
      "no-param-reassign": 0,
      "no-tabs": 1,
      "no-undef": 0,
      "no-unused-vars": 1,
      "one-var": 1,
      "prefer-const": 1,
    }
};

package.json

These are dev dependencies

    "eslint-config-airbnb": "^15.1.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.4.0",

I've managed to solve it by

npm uninstall eslint-config-airbnb
npm i --save-dev eslint-config-airbnb
npm i --save-dev eslint
npm i --save-dev babel-eslint
npm i --save-dev eslint-plugin-jsx-a11y
npm i --save-dev eslint-plugin-react

I ended up with those packages

    "eslint": "^4.15.0",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.5.1"

The main idea behind fix is to let eslint-config-airbnb install peer dependencies, after doing so I have no errors after lint and no warnings inside IDE(Webstorm2017.3.3)

Here is the working set of dependencies:

  "dependencies": {
    "eslint": "^4",
    "eslint-config-airbnb": "^16",
    "eslint-plugin-import": "^2",
    "eslint-plugin-jsx-a11y": "^6",
    "eslint-plugin-react": "^7",
    "babel-eslint": "^8",
    "eslint-plugin-compat": "^2"
  }

Check this npm package:

https://www.npmjs.com/package/eslint-config-airbnb-bundle

There you'll find instructions for WebStrom IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM