disallow unnecessary semicolons (no-extra-semi)

禁用不必要的分号 (no-extra-semi)

The --fix option on the command line can automatically fix some of the problems reported by this rule.

命令行中的 --fix 选项可以自动修复一些该规则报告的问题。

Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

书写错误和对哪里需要使用分号的误解,会导致出现不必要的分号。虽然在技术上不是个错误,但阅读代码时会引起困惑。

Rule Details

This rule disallows unnecessary semicolons.

该规则禁用不必要的分号。

Examples of incorrect code for this rule:

错误 代码示例:

/*eslint no-extra-semi: "error"*/

var x = 5;;

function foo() {
    // code
};

Examples of correct code for this rule:

正确 代码示例:

/*eslint no-extra-semi: "error"*/

var x = 5;

var foo = function() {
    // code
};

When Not To Use It

If you intentionally use extra semicolons then you can disable this rule.

如果你有意使用额外的分号,那么你可以禁用此规则。

Version

This rule was introduced in ESLint 0.0.9.

该规则在 ESLint 0.0.9 中被引入。

Resources


+