chore(prettier): set printWidth to 120 and reformat the repo - #79
Open
valthon wants to merge 3 commits into
Open
chore(prettier): set printWidth to 120 and reformat the repo#79valthon wants to merge 3 commits into
valthon wants to merge 3 commits into
Conversation
`.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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
.prettierrc.jsnever setprintWidth, 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:.ts/.tsxfiles failedprettier --checkonmaster.prettier --write(or enable format-on-save) without generating a repo-wide diff, so the formatter was unusable as a gate.Setting
printWidth: 120matches how the code is actually written and makesprettier --checka gate that can pass.Separately,
jsxBracketSameLinewas deprecated by prettier in favour ofbracketSameLine. Because the old key was still present, every prettier invocation printed:on every format, every check, and every editor-on-save run. The rename is behaviour-preserving (
falseis also the default) and removes the warning.The three commits
Review effort belongs almost entirely on the first commit.
df9dd976chore(prettier)— the config:printWidth: 120,jsxBracketSameLine→bracketSameLine5876736fstyle:— mechanicalprettier --writeoutput06fd06cechore(prettier)— scope prettier to TypeScript; remove the globalparserpinThe 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:
|dropped from a union now on one linetype X = A | Bvs the multi-line form;statement separators replaced by newlinessemi: false; separator becomes the newline{" "}↔ a literal spaceThis check is host-independent and is the strongest evidence in this PR.
Verification
prettier --check(655.ts/.tsx)pnpm buildpnpm run lintno-restricted-syntaxselectors and customwire-local/*rules)git diff --stat HEAD -- '*.md'empty, 0 filesjestmaster's own baseline, so the reformat is test-neutralReformat 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 runscontend across worktrees and fail as
ECOMPROMISED/wire-cluster-ports.locktimeouts inClusterConfigProviderandClusterBuildDefaults*— 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 ownbaseline exactly, which is the point — a pure formatting change must move neither number.
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.jspinnedparser: "typescript"globally, so prettier parsed every file asTypeScript. Markdown did not come back clean — it came back as
SyntaxError: Invalid character. (1:1), andpnpm format(glob**/*.{ts,tsx,md}) errored onall 14 markdown files on every run. The same pin masked every
.json,.yaml,.mjsandbin 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/.tsxfile changes, so the reformat above is byte-identicaleither way — scopes the
formatscript to**/*.{ts,tsx}, and adds a.prettierignorethatignores everything and re-includes
.ts/.tsx. The config now states plainly what was alreadytrue in practice: prettier owns TypeScript in this repo and nothing else.
Markdown stays hand-authored deliberately:
proseWrap: "always"at 120 columns would rewrapSTYLE.md, CLAUDE.md and the
.clauderules, whose line breaks carry meaning. Widening prettierto JSON/YAML/scripts would rewrite CI workflows and every
package.json— a decision worthmaking 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