space-after-keywords
在关键字之后强制执行一致的间距。
¥Enforces consistent spacing after keywords.
某些风格指南将要求或不允许在某些关键字后使用空格。
¥Some style guides will require or disallow spaces following the certain keywords.
if (condition) {
doSomething();
} else {
doSomethingElse();
}
if(condition) {
doSomething();
}else{
doSomethingElse();
}
规则详情
¥Rule Details
此规则将强制关键字 if
、else
、for
、while
、do
、switch
、try
、catch
、finally
和 with
之后的间距保持一致。
¥This rule will enforce consistency of spacing after the keywords if
, else
, for
, while
, do
, switch
, try
, catch
, finally
, and with
.
这条规则有一个参数。如果是 "always"
,那么关键字后面必须至少有一个空格。如果是 "never"
,那么后面应该没有空格。默认值为 "always"
。
¥This rule takes one argument. If it is "always"
then the keywords must be followed by at least one space. If "never"
then there should be no spaces following. The default is "always"
.
此规则的错误代码示例:
¥Examples of incorrect code for this rule:
/*eslint space-after-keywords: "error"*/
if(a) {}
if (a) {} else{}
do{} while (a);
/*eslint space-after-keywords: ["error", "never"]*/
if (a) {}
此规则的正确代码示例:
¥Examples of correct code for this rule:
/*eslint space-after-keywords: "error"*/
if (a) {}
if (a) {} else {}
/*eslint space-after-keywords: ["error", "never"]*/
if(a) {}
版本
此规则是在 ESLint v0.6.0 中引入,并在 v2.0.0-beta.3 中删除。