简体   繁体   中英

Eslint - eslint-config-airbnb not find

I'm getting some errors module eslint-config-airbnb not found , when run command eslint **/*.jsx .

package.json file

{
  "name": "reactapp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "precommit": "npm test",
    "start": "webpack-dev-server --hot"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "husky": "^0.14.3",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "webpack": "^3.5.5",
    "webpack-dev-server": "^2.7.1"
  },
  "devDependencies": {
    "eslint-config-airbnb": "^15.1.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.3.0"
  }
}

eslintrc file

{ "extends": "airbnb" }

Check to see if your eslint has been installed / installed correctly. Also reinstall your node_modules folder as well, if eslint has been configured.

Since eslint isn't in your devDependencies, I assumed you've got it set up globally?

I've copied your package.json set up, but tested it with a local eslint and it's working for me.

"scripts": 
{
    "precommit": "npm test",
    "start": "webpack-dev-server --hot",
    "lint": "eslint **/*.jsx --fix"
}

...

"devDependencies": 
{
    "eslint": "^4.5.0",
    "eslint-config-airbnb": "^15.1.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.3.0" 
}
npm install -D rimraf prettier babel-eslint eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-import eslint-config-prettier eslint-config-airbnb eslint-plugin-react-hooks
npm run build

Try running this, worked for me.

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