Skip to content

Trailing commas are swift-format's default now that oida holds no rule - #333

Closed
3lvis wants to merge 1 commit into
masterfrom
elvis/trailing-commas-are-the-formatters
Closed

3lvis wants to merge 1 commit into
masterfrom
elvis/trailing-commas-are-the-formatters

Conversation

@3lvis

@3lvis 3lvis commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Why

multiElementCollectionTrailingCommas: false was a truce, and the other side of it is gone.

swift-format defaults the option to true, so it adds a trailing comma to a multi-line literal. oida's trailing_comma rule defaulted to mandatoryComma = false, so it flagged that same comma. Two default-on tools with opposite instructions on one character — the key is what kept them from undoing each other on every run. oida 0.16.0 deleted trailing_comma ("Trailing commas are the formatter's"), so the key now referees a fight with one side in it.

With it gone, swift-format's default stands: a multi-line literal ends with a comma, so adding an element touches one line rather than two and the diff says what changed. Sixteen lines picked that up from bin/lint --fix.

.swift-format is down to the three keys that say something — a version, a width, an indent.

The approach

Measured the same way as #332: formatting the tree with and without the key, and reading what moved. The products: array keeps its shape, since the option speaks only for collections with several elements.

Testing

make test (180 tests, green) plus bin/lint --check clean.

Learnings

A config key that duplicates a default is easy to spot; one that contradicts a default is the one worth re-reading, because it usually holds a truce with some other tool, and truces outlive their counterparties silently. #332 pruned the duplicates and kept this one on the grounds that it changed output — which answered whether it did something, rather than whether the something was still wanted.

@3lvis 3lvis closed this Sep 16, 2026
@3lvis
3lvis deleted the elvis/trailing-commas-are-the-formatters branch September 16, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant