comma-style
Configuration
Enforce consistent comma style.
Rule Details
This rule enforces a consistent comma placement across comma-separated lists in JavaScript and TypeScript — array literals, object literals, variable declarations, function parameters, call arguments, import / export specifiers, sequence expressions, and the TypeScript-only lists (type / interface members, enum members, tuples, type parameters and type arguments, function / constructor signatures, import attributes).
The rule does NOT flag commas in single-line lists. A comma surrounded by linebreaks on both sides (a "lone" comma) reports under its own message regardless of the configured style.
Options
This rule has a string option:
"last"(default) — commas at the end of the current line."first"— commas at the start of the next line.
This rule has an object option:
"exceptions"— disables the rule for specific AST node types. Keys match the upstream ESTree /@typescript-eslint/parsernode-type names so configuration is portable from ESLint Stylistic. Supported keys:ArrayExpression,ArrayPattern,ObjectExpression,ObjectPattern,VariableDeclaration,FunctionDeclaration,FunctionExpression,ArrowFunctionExpression,CallExpression,NewExpression,ImportExpression,ImportDeclaration,ExportNamedDeclaration,ExportAllDeclaration,SequenceExpression,ClassDeclaration,ClassExpression,TSDeclareFunction,TSFunctionType,TSConstructorType,TSEmptyBodyFunctionExpression,TSMethodSignature,TSCallSignatureDeclaration,TSConstructSignatureDeclaration,TSEnumBody,TSTypeLiteral,TSInterfaceBody,TSInterfaceDeclaration,TSIndexSignature,TSTupleType,TSTypeParameterDeclaration,TSTypeParameterInstantiation.
last
Examples of incorrect code for this rule with the default "last" option:
Examples of correct code for this rule with the default "last" option:
first
Examples of incorrect code for this rule with the "first" option:
Examples of correct code for this rule with the "first" option:
exceptions
Examples of correct code for this rule with "first", { "exceptions": { "ArrayExpression": true, "ObjectExpression": true } }: