no-space-before-semi

分号前不允许有空格。

¥Disallows spaces before semicolons.

JavaScript 允许在表达式和结束分号之间放置不必要的空格。

¥JavaScript allows for placing unnecessary spaces between an expression and the closing semicolon.

空间问题还可能导致代码看起来不一致且难以阅读。

¥Space issues can also cause code to look inconsistent and harder to read.

var thing = function () {
  var test = 12 ;
}  ;

规则详情

¥Rule Details

此规则防止在表达式中的分号前使用空格。

¥This rule prevents the use of spaces before a semicolon in expressions.

此规则的错误代码示例:

¥Examples of incorrect code for this rule:

var foo = "bar" ;

var foo = function() {} ;

var foo = function() {
} ;

var foo = 1 + 2 ;

此规则的正确代码示例:

¥Examples of correct code for this rule:

;(function(){}());

var foo = "bar";

版本

此规则是在 ESLint v0.4.3 中引入,并在 v1.0.0-rc-1 中删除。