【问题标题】:Failed to install eslint with react-native project使用 react-native 项目安装 eslint 失败
【发布时间】:2017-06-16 16:10:10
【问题描述】:

我有一个 react-native 项目,想使用 eslint 进行样式检查。但是运行eslint app/ 命令时出现以下错误:

ESLint couldn't find the plugin "eslint-plugin-jsx-a11y". This can happen for a couple different reasons:
  1. 如果 ESLint 是全局安装的,那么请确保 eslint-plugin-jsx-a11y 也全局安装。全局安装的 ESLint 找不到本地安装的插件。

  2. 如果 ESLint 是本地安装的,那么很可能是插件没有正确安装。尝试通过运行重新安装 以下:

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

如果您仍然无法解决问题,请通过https://gitter.im/eslint/eslint 与团队交流。

下面是我的 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"
  }

我已经搜索过有人说关于对等依赖的这个问题。而且我尝试了不同的版本组合仍然不起作用。

【问题讨论】:

    标签: reactjs react-native eslint


    【解决方案1】:

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

    2-

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

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

    【讨论】:

      猜你喜欢
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-05
      • 2019-06-13
      • 2019-01-14
      相关资源
      最近更新 更多