1 | # `comma-dangle`
|
2 |
|
3 | Require or disallow trailing comma.
|
4 |
|
5 | ## Rule Details
|
6 |
|
7 | This rule extends the base [`eslint/comma-dangle`](https://eslint.org/docs/rules/comma-dangle) rule.
|
8 | It adds support for TypeScript syntax.
|
9 |
|
10 | See the [ESLint documentation](https://eslint.org/docs/rules/comma-dangle) for more details on the `comma-dangle` rule.
|
11 |
|
12 | ## Rule Changes
|
13 |
|
14 | ```jsonc
|
15 | {
|
16 | // note you must disable the base rule as it can report incorrect errors
|
17 | "comma-dangle": "off",
|
18 | "@typescript-eslint/comma-dangle": ["error"]
|
19 | }
|
20 | ```
|
21 |
|
22 | In addition to the options supported by the `comma-dangle` rule in ESLint core, the rule adds the following options:
|
23 |
|
24 | ## Options
|
25 |
|
26 | This rule has a string option and an object option.
|
27 |
|
28 | - Object option:
|
29 |
|
30 | - `"enums"` is for trailing comma in enum. (e.g. `enum Foo = {Bar,}`)
|
31 | - `"generics"` is for trailing comma in generic. (e.g. `function foo<T,>() {}`)
|
32 | - `"tuples"` is for trailing comma in tuple. (e.g. `type Foo = [string,]`)
|
33 |
|
34 | - [See the other options allowed](https://eslint.org/docs/rules/comma-dangle#options)
|
35 |
|
36 | <sup>
|
37 |
|
38 | Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/comma-dangle.md)
|
39 |
|
40 | </sup>
|
41 |
|
42 | ## Attributes
|
43 |
|
44 | - Configs:
|
45 | - [ ] ✅ Recommended
|
46 | - [ ] 🔒 Strict
|
47 | - [x] 🔧 Fixable
|
48 | - [ ] 💭 Requires type information
|