Skip to main content

comma-spacing

danger
We strongly recommend you do not use this rule or any other formatting linter rules. Use a separate dedicated formatter instead. See What About Formatting? for more information.

Enforce consistent spacing before and after commas.

🛠

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

Examples

This rule extends the base eslint/comma-spacing rule. It adds support for trailing comma in a types parameters list.

How to Use

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"comma-spacing": "off",
"@typescript-eslint/comma-spacing": "warn"
}
};

Options

See eslint/comma-spacing options.

Taken with ❤️ from ESLint core

Resources