如何在Atom Editor上配置ESLint for React [英] How to config ESLint for React on Atom Editor
问题描述
在Atom编辑器中,我安装了以下插件
In Atom Editor I installed the following plugins
- 线性
- linter-eslint
似乎他们不认识JSX语法.
It seems they don't recognize the JSX syntaxis.
我可以在命令行上使用它,但是必须使用其他插件,例如esprima-fb
和eslint-plugin-react
.似乎没有适用于Atom Editor的插件,并且想知道你们中是否有人知道解决此问题的方法.
I have it working on the command line but had to use other plugins like esprima-fb
and eslint-plugin-react
. Looks like there are no such plugins for Atom Editor and would like to know if anyone of you knows a way to hack around this.
推荐答案
要使Eslint与React.js良好配合:
To get Eslint working nicely with React.js:
- 安装lint& linter-eslint插件
- 运行
npm install eslint-plugin-react
- 将
"plugins": ["react"]
添加到您的.eslintrc配置文件中 - 将
"ecmaFeatures": {"jsx": true}
添加到您的.eslintrc配置文件中
- Install linter & linter-eslint plugins
- Run
npm install eslint-plugin-react
- Add
"plugins": ["react"]
to your .eslintrc config file - Add
"ecmaFeatures": {"jsx": true}
to your .eslintrc config file
以下是.eslintrc
配置文件的示例:
Here is an example of a .eslintrc
config file:
{
"env": {
"browser": true,
"node": true
},
"globals": {
"React": true
},
"ecmaFeatures": {
"jsx": true
},
"plugins": [
"react"
]
}
此刻我正在使用Eslint v1.1.0.
I am using Eslint v1.1.0 at the moment.
旁注:
我必须同时安装eslint和eslint-plugin-react作为项目依赖项(例如npm install eslint eslint-plugin-react --save-dev
).希望这会有所帮助.
Side note:
I had to install both eslint and eslint-plugin-react as project dependencies (e.g., npm install eslint eslint-plugin-react --save-dev
). Hopefully this helps.
这篇关于如何在Atom Editor上配置ESLint for React的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!