在 Atom Editor 中我安装了以下插件
- 短绒检查
- linter-eslint
他们似乎无法识别 JSX 语法。
我让它在命令行上运行,但必须使用其他插件,例如 esprima-fb 和 eslint-plugin-react 。看起来 Atom Editor 没有这样的插件,想知道你们中是否有人知道解决这个问题的方法。
最佳答案
为了让 Eslint 与 React.js 完美配合:
- 安装 linter 和 linter-eslint 插件
- 运行
npm install eslint-plugin-react
- 将
"plugins": ["react"]
添加到您的 .eslintrc 配置文件 - 将
"ecmaFeatures": {"jsx": true}
添加到您的 .eslintrc 配置文件
以下是 .eslintrc
配置文件的示例:
{
"env": {
"browser": true,
"node": true
},
"globals": {
"React": true
},
"ecmaFeatures": {
"jsx": true
},
"plugins": [
"react"
]
}
我现在使用的是 Eslint v1.1.0。
旁注: 我必须安装 eslint 和 eslint-plugin-react 作为项目依赖项(例如,npm install eslint eslint-plugin-react --save-dev)。希望这会有所帮助。
关于atom-editor - 如何在 Atom 编辑器上为 React 配置 ESLint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30294870/