linter
和linter-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时出现错误
以下是开发工具的堆栈跟踪:
/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
肯定安装在项目中。我缺少什么想法?
答案 0 :(得分:-1)
对我来说,删除这一行有效:
"parser": "babel-eslint",