Skip to main content

no-extra-semi

<admonition title="Deprecated" type="warning"> Formatting rules now live in <a href="https://eslint.style">eslint-stylistic</a>. <a href="https://eslint.style/rules/ts/no-extra-semi">@stylistic/ts/no-extra-semi</a> is the replacement for this rule. <br /> See <a href="/blog/deprecating-formatting-rules">Deprecating Formatting Rules</a> for more information. </admonition>

Disallow unnecessary semicolons.

🔧

Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.

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

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.

Options

See eslint/no-extra-semi options.

How to Use

.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"
}
};

Try this rule in the playground ↗

Resources

Taken with ❤️ from ESLint core.