Skip to content

chore: format fork-touched files and gate formatting on commit - #261

Merged
quickbeard merged 2 commits into
mainfrom
prettier-fork-files
Aug 18, 2026
Merged

quickbeard merged 2 commits into
mainfrom
prettier-fork-files

Conversation

@quickbeard

@quickbeard quickbeard commented Aug 18, 2026 •

Copy link
Copy Markdown
Owner

Two commits: a one-time formatting cleanup, and the hook that stops the drift from coming back.

1. chore: format fork-touched files with prettier

Ran prettier --write over every file this fork adds or modifies relative to upstream v1.18.4 (the tag in packages/opencode/package.json). Of the 705 prettier-eligible fork-touched files, 67 were unformatted; the rest were already clean.

Why this is safe to do to upstream files. The formatting drift is entirely fork-authored. I extracted the upstream v1.18.4 version of each of the 34 modified-upstream files in the unformatted set and checked them: all 34 are prettier-clean upstream. So this restores upstream's own formatting conventions on regions the fork edited, which shrinks conflict surface on the next sync rather than adding to it. No new divergence is introduced by the formatting itself — these files already diverge; only their whitespace changes.

Exclusion: packages/web/src/content/docs/. Added to .prettierignore, with the reasoning inline and the existing .prettierignore row in DIVERGENCES.md extended:

  • It is the upstream docs merge base (packages/web/FORK-DOCS.md). Nothing in this repo builds it; its whole job is to make upstream doc changes surface during a sync. Reformatting it is pure conflict surface for zero user-facing benefit — the published docs live in codev-landing-page.
  • Prettier's MDX printer actively mangles index.mdx, collapsing the fenced code blocks inside <TabItem> into inline text.

2. chore: format staged files with lint-staged on commit

The drift above accumulated because nothing enforced formatting — the only hook was pre-push, and it runs bun typecheck alone.

  • .husky/pre-commit (fork-only; upstream ships pre-push only) runs bunx lint-staged.
  • Root manifest gains a lint-staged block mapping every staged path to prettier --write --ignore-unknown, plus the lint-staged devDependency.
  • --ignore-unknown skips paths Prettier has no parser for (bun.lock, .husky/*, binaries) instead of failing the commit; .prettierignore still exempts DIVERGENCES.md and the docs merge base.

DIVERGENCES.md rows updated for the root package.json and bun.lock.

Verification

  • prettier --check over the full fork-touched set: clean, and a rerun of --write over the PR's own files is a no-op (idempotent).
  • bun turbo typecheck: 33/33, including via the pre-push hook.
  • Touched test files re-run and passing (packages/tui util/routes tests, packages/opencode provider transform: 386 tests).
  • Hook exercised end-to-end with a deliberately unformatted staged file — reformatted and re-staged, and the resulting commit contained the formatted version. Confirmed on this PR's own commit that DIVERGENCES.md passed through untouched.
  • All non-whitespace hunks reviewed — line reflow, trailing commas, and *em* → _em_ only.

No behavior change, so no CHANGELOG.md entry.

🤖 Generated with Claude Code

Ran prettier --write over every file this fork adds or modifies relative to
upstream v1.18.4 (the tag in packages/opencode/package.json). 67 files were
unformatted; the rest were already clean.

The formatting drift is entirely fork-authored: of the 34 modified upstream
files in that set, all 34 are prettier-clean at v1.18.4, so this restores
upstream's own formatting conventions rather than imposing new ones. That
shrinks conflict surface on the next sync instead of adding to it.

packages/web/src/content/docs/ is excluded via .prettierignore. It is the
upstream docs merge base (packages/web/FORK-DOCS.md) — nothing builds it, and
its only job is to surface upstream doc diffs during a sync, so reformatting
it is pure conflict surface. Prettier's MDX printer also mangles index.mdx,
collapsing the fenced code blocks inside <TabItem> into inline text.

No behavior change: bun turbo typecheck passes (33/33) and the touched test
files still pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard force-pushed the prettier-fork-files branch from d347c0c to b3df34c Compare August 18, 2026 02:41
PR #261 had to clean up 67 files' worth of Prettier drift that accumulated
because nothing enforced formatting — the only hook was pre-push, and it runs
`bun typecheck` alone. This adds the missing gate so that drift cannot silently
reaccumulate.

`.husky/pre-commit` (fork-only; upstream ships pre-push only) runs `bunx
lint-staged`, and the root manifest's new `lint-staged` block maps every staged
path to `prettier --write --ignore-unknown`. lint-staged re-stages what Prettier
rewrites, so the commit lands formatted.

`--ignore-unknown` skips paths Prettier has no parser for (`bun.lock`,
`.husky/*`, binaries) instead of failing the commit, and `.prettierignore` still
exempts `DIVERGENCES.md` and the `packages/web/src/content/docs/` merge base.

Verified end-to-end with a deliberately unformatted staged file: the hook
reformatted it and the resulting commit contained the formatted version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard quickbeard changed the title chore: format fork-touched files with prettier chore: format fork-touched files and gate formatting on commit Aug 18, 2026
@quickbeard
quickbeard merged commit ba1a61e into main Aug 18, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the prettier-fork-files branch August 18, 2026 03:09
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