Skip to main content

comma-dangle

Requires or disallows trailing commas.

Attributes

  • Included in configs
    • ✅ Recommended
    • 🔒 Strict
  • Fixable
    • 🔧 Automated Fixer
    • 🛠 Suggestion Fixer
  • 💭 Requires type information

Rule Details

This rule extends the base eslint/comma-dangle rule. It adds support for TypeScript syntax.

See the ESLint documentation for more details on the comma-dangle rule.

How to Use

{
// note you must disable the base rule as it can report incorrect errors
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": ["error"]
}

In addition to the options supported by the comma-dangle rule in ESLint core, the rule adds the following options:

Options

This rule has a string option and an object option.

  • Object option:

    • "enums" is for trailing comma in enum. (e.g. enum Foo = {Bar,})
    • "generics" is for trailing comma in generic. (e.g. function foo<T,>() {})
    • "tuples" is for trailing comma in tuple. (e.g. type Foo = [string,])
  • See the other options allowed

Taken with ❤️ from ESLint core