eslint无法在Atom中用于响应本机项目

时间:2017-07-13 02:50:40

标签: react-native atom-editor eslint

linterlinter-eslint模块安装在Atom

创建反应原生项目

react-native init AwesomeApp

安装必需的节点模块

yarn add babel-eslint eslint-config-airbnb-base eslint-plugin-react eslint-plugin-react-native --dev

创建.eslintrc文件:

{
  "parser": "babel-eslint",
  "plugins": [
    "react",
    "react-native"
  ],
  "parserOptions": {
    "ecmaFeatures": {
        "jsx": true,
        "modules": true
    }
  },
  "extends" : [
    "eslint:recommended",
    "plugin:react/recommended",
    "airbnb-base"
  ],
  "rules" : {
    "arrow-body-style" : 'warn'
  }
}

当我打开Atom时出现错误

Atom eslint error

以下是开发工具的堆栈跟踪:

/Volumes/Macintosh HD 3/.atom/packages/linter/lib/linter-registry.js:159 [Linter] Error running ESLint Error: Failed to load plugin react-native: Cannot find module 'eslint-plugin-react-native'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.resolve (internal/module.js:27:19)
    at Object.load (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config/plugins.js:134:29)
    at Array.forEach (native)
    at Object.loadAll (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config/plugins.js:162:21)
    at Object.load (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:541:21)
    at loadConfig (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config.js:63:33)
    at new Config (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config.js:229:42)
    at CLIEngine.executeOnText (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:741:28)
    at lintJob (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/lib/worker.js:50:51)

Atom是最新的,我正在运行1.18.0 x64

eslint-plugin-react-native肯定安装在项目中。我缺少什么想法?

1 个答案:

答案 0 :(得分:-1)

对我来说,删除这一行有效:

"parser": "babel-eslint",