Skip to main content


This rule will soon be moved to eslint-stylistic. See What About Formatting? for more information.

Require or disallow trailing commas.


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

此规则扩展了基本 eslint/comma-dangle 规则。 它添加了对 TypeScript 语法的支持。

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

有关 comma-dangle 规则的更多详细信息,请参阅 ESLint 文档

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


除了 ESLint 核心中 comma-dangle 规则支持的选项外,该规则还添加了以下选项:

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

  • "enums" 用于枚举中的尾随逗号。 (例如 enum Foo = {Bar,}
  • "generics" 用于通用中的尾随逗号。 (例如 function foo<T,>() {}
  • "tuples" 用于元组中的尾随逗号。 (例如 type Foo = [string,]


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


参见 eslint/comma-dangle 选项


摘自 ❤️ ESLint 内核