Skip to content
Latchkey

Prettier trailingComma: all, es5, none

trailingComma decides whether Prettier adds trailing commas to multi-line lists; the Prettier 3 default is "all".

Trailing commas keep diffs small because adding a line does not also touch the line above. The default changed in Prettier 3, which matters for CI.

What it does

trailingComma sets where Prettier puts trailing commas in multi-line arrays, objects, function arguments, and parameters. "all" adds them everywhere including function calls and parameters (valid in modern JS and TS). "es5" adds them only where ES5 allows (arrays, objects). "none" adds none. The default is "all" as of Prettier 3 (it was "es5" in Prettier 2).

Common usage

.prettierrc.json
// .prettierrc.json
{ "trailingComma": "all" }

// output with "all"
function f(
  a,
  b,
) {}

Options

ValueWhat it does
all (default in v3)Trailing commas everywhere allowed in modern JS/TS
es5Only where ES5 permits (arrays, objects)
noneNo trailing commas
--trailing-comma <value>Set it on the CLI

In CI

The default flip from es5 to all in Prettier 3 reformats function calls and parameter lists across the codebase. After upgrading Prettier major versions, run prettier --write . in one commit so the next --check is clean, and pin the Prettier version so CI and local agree on the default.

Common errors in CI

A large "Code style issues found" diff right after a Prettier 2 to 3 upgrade is almost always the trailingComma default changing to all. Reformat once and commit. If you must keep the old behavior temporarily, set "trailingComma": "es5" explicitly.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →