无法使用react-native项目安装eslint

时间:2017-01-31 09:30:06

标签: reactjs react-native eslint airbnb

我有一个本机反应项目,并希望使用eslint进行样式检查。但是在运行eslint app/命令时出现以下错误:

ESLint couldn't find the plugin "eslint-plugin-jsx-a11y". This can happen for a couple different reasons:

1. If ESLint is installed globally, then make sure eslint-plugin-jsx-a11y is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.

2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm i eslint-plugin-jsx-a11y@latest --save-dev

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
下面的

是我的package.json文件:

"dependencies": {
    "react": "15.4.2",
    "react-native": "0.40.0",
    "react-redux": "^5.0.2",
    "redux": "^3.6.0",
    "redux-actions": "^1.2.1",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-jest": "18.0.0",
    "babel-preset-react-native": "1.9.1",
    "eslint": "^3.14.1",
    "eslint-config-airbnb": "^14.0.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^3.0.2",
    "eslint-plugin-react": "^6.9.0",
    "jest": "18.1.0",
    "react-test-renderer": "15.4.2"
  },
  "jest": {
    "preset": "react-native"
  }

我搜索过这个问题有人说同伴依赖。我试过不同的版本组合仍然无法正常工作。

1 个答案:

答案 0 :(得分:0)

1-在项目中本地安装ESLint和插件。全局或在包配置中安装插件是一种破解。

2-

cd ~/.atom/packages/linter-eslint/
    npm install eslint-plugin-react

如果这不起作用,请尝试查看此处,这可能会对您有所帮助https://github.com/AtomLinter/linter-eslint/issues/422