[英]ESLint with Airbnb style guide does not work for all rules
Recently I started checking all various JavaScript style guides and I liked Airbnb the best.最近我开始查看各种 JavaScript 风格指南,我最喜欢Airbnb 。
However, when I configured ESLint with Airbnb style guide, I noticed that some rules defined in their docs are not checked at all.但是,当我使用 Airbnb 样式指南配置ESLint时,我注意到他们的文档中定义的一些规则根本没有被检查。 For example:
例如:
consts
and then group all your lets
. consts
分组,然后将所有lets
分组。//
for single line comments.//
单行注释。 Place single line comments on a newline above the subject of the comment. So, if you take this code as an example:所以,如果你以这段代码为例:
const array = [1, 2, 3, 4, 5];
let foo = 'foo';
const bar = 'bar';
if (array.length) {
console.log('Bar:', bar);
// Chaniging foo
foo = 'baz';
console.log('Foo:', foo);
}
The linter should throw 3 errors: linter 应该抛出 3 个错误:
array.length > 0
.array.length > 0
。 However, linter does not throw any error.但是,linter 不会抛出任何错误。
Airbnb style guide is a recommendation on how to write code. Airbnb 风格指南是关于如何编写代码的建议。
ESLint is a tool created by a separate team, specifically Nicholas C. ESLint 是由一个单独的团队创建的工具,特别是 Nicholas C。 Zakas in the first place.
首先是扎卡斯。
So the recommendation utilizes ESLint to automate checks for some of the rules, but not all.所以推荐使用 ESLint 来自动检查一些规则,但不是全部。
Some Airbnb style guide rules have trailing eslint: rule-name
, which indicates if it is checked or not.一些 Airbnb 风格指南规则有尾随
eslint: rule-name
,表示它是否被选中。 All 3 rules from the topic don't have it.该主题的所有 3 条规则都没有。
Also there is a page that elaborates on new rules addition.还有一个 页面详细说明了新规则的添加。 It states: "As of 2020, we only accept rules related to new ECMAScript features. We prefer that new rules be implemented in plugins".
它指出:“截至 2020 年,我们只接受与新 ECMAScript 功能相关的规则。我们更喜欢在插件中实现新规则”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.