Javascript Intellij插件:AirBnB ESLint w/React
在Ubuntu15.10上使用IntellijIDEA 15.0.2,并尝试配置ESLint工作 按照Jetbrains网站上的说明操作,但没有骰子 语言和框架>javascript>代码质量工具>ESLint的设置。IntelliJ中我的nodejs/npm设置 以及根项目目录中的myJavascript Intellij插件:AirBnB ESLint w/React,javascript,intellij-idea,reactjs,eslint,Javascript,Intellij Idea,Reactjs,Eslint,在Ubuntu15.10上使用IntellijIDEA 15.0.2,并尝试配置ESLint工作 按照Jetbrains网站上的说明操作,但没有骰子 语言和框架>javascript>代码质量工具>ESLint的设置。IntelliJ中我的nodejs/npm设置 以及根项目目录中的my.eslintrc文件: { "extends": "airbnb", "rules": { "comma-dangle": 0 } } 下面是一个来自/index.js的剪报,它不会在In
.eslintrc
文件:
{
"extends": "airbnb",
"rules": {
"comma-dangle": 0
}
}
下面是一个来自/index.js
的剪报,它不会在IntelliJ中产生错误或警告:
var superman = {
default: { clark: "kent" },
private: true
};
以下是我从终端运行eslint index.js
时的输出:
4:1 error Unexpected var, use let or const instead no-var
5:5 error Expected indentation of 2 space characters but found 4 indent
5:23 error Strings must use singlequote quotes
6:5 error Expected indentation of 2 space characters but found 4 indent
注意:我相信ESLint正在运行,因为在我将.eslintrc
更改为AirBNB版本之前,我使用的是Github的.eslintrc
,它在IntelliJ中抛出了许多ESLint错误(即.eslintrc
文件本身的错误,而不是我的代码)
但是,一旦我修复了这些错误,插件就会安静下来,当我通过产生错误来测试它时,它不会对我大喊大叫。JetBrains(Idea,Webstorm)设置
文件>设置>插件>浏览存储库…>搜索:eslint>安装>重新启动WebStorm
File>Settings>Languages&Frameworks>JavaScript>code质量工具>ESLint
之后,它应该像这样工作:
ESLint配置
ESLint没有配置。您必须创建自己的或使用预设:
npm install --save-dev eslint-config-airbnb eslint
然后在你的.eslintrc中
{
"extends": "airbnb"
}
您还可以从预设中有选择地禁用/修改某些规则(0-禁用规则,1-警告,2-错误):
阅读:
如果您不想使用airbnb配置(最流行的javascript样式指南),您可以创建自己的。以下是react的说明:
要创建自己的预设,您必须创建名为eslint config myname的npm包,然后使用'extends':'myname',
您可以使用命令行检查eslint是否工作:
./node_modules/.bin/eslint .
不过,您可以在.eslintingle中从eslinting中排除某些文件(默认情况下排除节点_模块):
bundle.js
eslint还有一个--fix
开关
.编辑配置
ESLint的好伴侣是editorconfig。以下是一个适用于JetBrains产品的示例:
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,jsx,html,sass}]
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
# don't use {} for single extension. This won't work: [*.{css}]
[*.css]
indent_style = space
indent_size = 2
我还有一个github存储库,它已经设置了这些文件
基于此,
此处的更多内容在rep Limitions的OP b/c中发布的链接不能超过2个,因此:这导致了我在配置ESLint IntelliJ插件时出现的错误。也许这会对wow有所帮助。我怎么会错过这个——谢谢,我基本上已经放弃了。如果您想将其作为答案发布,我将标记为已接受。您还必须使用
babel parer
,否则airbnb扩展将不起作用correctly@BruceLee你谈过这个吗?
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,jsx,html,sass}]
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
# don't use {} for single extension. This won't work: [*.{css}]
[*.css]
indent_style = space
indent_size = 2