Skip to main content

no-extra-semi

Disallow unnecessary semicolons.

🔧

此规则报告的一些问题可通过 --fix ESLint 命令行选项自动修复


此规则扩展了基本 eslint/no-extra-semi 规则。 它添加了对类属性的支持。

英:This rule extends the base eslint/no-extra-semi rule. It adds support for class properties.

请注意,该规则被归类为 "建议" 规则而不是 "布局和格式" 规则,因为 添加额外的分号实际上会改变程序的 AST。 话虽如此,现代 TypeScript 格式化程序将在格式化过程中自动删除多余的分号。 因此,如果你 使用格式化程序,那么启用此规则可能是不必要的。

英:Note that this rule is classified as a "Suggestion" rule instead of a "Layout & Formatting" rule because adding extra semi-colons actually changes the AST of the program. With that said, modern TypeScript formatters will remove extra semi-colons automatically during the formatting process. Thus, if you use a formatter, then enabling this rule is probably unnecessary.

如何使用

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"no-extra-semi": "off",
"@typescript-eslint/no-extra-semi": "error"
}
};
在线运行试试这个规则 ↗

选项

参见 eslint/no-extra-semi 选项

资源

摘自 ❤️ ESLint 内核