Skip to content

chore: replace prettier with oxfmt and enforce format:check in CI - #277

Open
LukeSheard wants to merge 2 commits into
mainfrom
oxfmt-formatting-ci
Open

chore: replace prettier with oxfmt and enforce format:check in CI#277
LukeSheard wants to merge 2 commits into
mainfrom
oxfmt-formatting-ci

Conversation

@LukeSheard

@LukeSheard LukeSheard commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

The repo has no formatting gate. Prettier is wired into a pre-commit hook, but nothing verifies formatting in CI, so files drift out of shape and PRs end up carrying whitespace-only churn alongside real changes. 68 committed JS/TS files were already not formatted.

Change

Replace Prettier with oxfmt (the oxc formatter) as the repo's only formatter, and fail CI when anything isn't formatted.

  • .oxfmtrc.json — oxfmt covers every file type it understands: JS, TS, JSON, Markdown, YAML, CSS. ignorePatterns only excludes build output (dist, .next, .turbo, …); oxfmt already skips lockfiles, dot-directories and file types it doesn't handle (binaries, SVG). 289 files are covered.
  • Prettier removed — the prettier devDependency is gone, along with its lint-staged entry and the CONTRIBUTING reference. The only prettier left in the lockfile is 2.8.8, vendored inside @changesets/write.
  • Scriptspnpm run format and pnpm run format:check at the root.
  • CI — a new Format workflow runs pnpm run format:check on every pull request and on pushes to main. It's a separate job from Publish so formatting feedback is fast and a format failure can't wedge a release.
  • lint-staged — collapsed to a single * group running oxfmt. Since oxfmt no-ops on unsupported files, the glob doesn't need to enumerate extensions, and one group removes the concurrent git add race the two groups had.
  • Reformat — the 68 JS/TS files that weren't already formatted.

Two config choices worth a look

printWidth: 80 rather than oxfmt's default of 100. 80 matches the repo's existing Prettier-formatted style; 100 would have reflowed ~123 files (−1200 net lines) instead of 68. Easy to flip later as its own PR.

sortPackageJson: false — this defaults to true and reorders package.json keys and sorts dependency lists. That's a source transformation rather than formatting, it's not something Prettier ever did, and it would make the changesets release PR fail the format check whenever it rewrote a manifest. Left off deliberately.

Notes on the diff

The bulk of this PR is the mechanical JS/TS reformat. The reviewable part is .oxfmtrc.json, package.json, .github/workflows/format.yml, and CONTRIBUTING.md.

Most reformatted hunks are cases where oxfmt follows Prettier 3.6+'s ternary and type-parameter formatting while the repo is on Prettier 3.5.3 — plus a handful of lines that simply exceeded 80 columns and were never formatted at all. Dropping Prettier cost zero extra churn: every JSON, Markdown, YAML and CSS file in the repo already matched oxfmt's output.

Verification

  • pnpm run format:check — clean, 289 files
  • git diff --check — clean
  • pnpm run build (typecheck + build, 8 tasks) — passing
  • packages/vercel-sandbox-mock tests — 195 passed, 86 skipped
  • lint-staged exercised against staged .ts, .json, .md and .yaml (all formatted) and a binary .ico (untouched)

The @vercel/sandbox and sandbox test suites hit the real API and weren't run locally.

Adopt oxfmt (the oxc formatter) for JavaScript and TypeScript, and gate
pull requests on a formatting check so they can't carry whitespace-only
churn.

- Add `oxfmt` and `.oxfmtrc.json`. `printWidth` is pinned to 80 to match
  the repo's existing Prettier-formatted style; every other option is
  left at oxfmt's Prettier-compatible default.
- `ignorePatterns` keeps oxfmt off build output and off the file types
  Prettier still owns (JSON, Markdown, YAML, CSS).
- Add `pnpm run format` and `pnpm run format:check` at the root.
- Add a `Format` workflow that runs `pnpm run format:check` on pull
  requests and on pushes to `main`.
- Switch the lint-staged JS/TS entry from Prettier to oxfmt, and widen
  its glob to cover `examples/` and the remaining JS/TS extensions.
  Prettier keeps handling JSON and Markdown.
- Reformat the 68 JS/TS files that were not already formatted.

Co-Authored-By: LukePS <9877376+LukeSheard@users.noreply.github.com>
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox Ready Ready Preview, v0 Aug 7, 2026 12:07pm
sandbox-cli Ready Ready Preview Aug 7, 2026 12:07pm
sandbox-sdk-ai-example Ready Ready Preview Aug 7, 2026 12:07pm
workflow-code-runner Ready Ready Preview Aug 7, 2026 12:07pm

@socket-security

socket-security Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​oxfmt@​0.62.0861008896100

View full report

Comment on lines +15 to +34
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
run_install: false

- uses: actions/setup-node@v4
with:
node-version: "24.16.0"
cache: "pnpm"

- run: pnpm install
shell: bash

- name: Check formatting
run: pnpm run format:check
oxfmt already handles JSON, Markdown, YAML and CSS, so there is no
reason to keep a second formatter around.

- Remove the `prettier` devDependency. The only remaining `prettier` in
  the lockfile is 2.8.8, vendored inside `@changesets/write`.
- Drop the per-language `ignorePatterns` from `.oxfmtrc.json` so oxfmt
  covers every file type it understands. Coverage goes from 216 to 289
  files, and none of the newly covered files needed reformatting.
- Set `sortPackageJson: false`. It defaults to true and reorders
  `package.json` keys and dependency lists, which is a source
  transformation rather than formatting, and would make the changesets
  release PR fail the format check whenever it rewrote a manifest.
- Collapse lint-staged to a single `*` group running oxfmt. oxfmt skips
  file types it does not understand (binaries, SVG), so the glob does
  not need to enumerate extensions, and the single group removes the
  concurrent `git add` race the two groups had.

Co-Authored-By: LukePS <9877376+LukeSheard@users.noreply.github.com>
Comment thread package.json
],
"*.{json,md}": [
"prettier --write",
"*": [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"*": [
"*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json,jsonc,json5}": [

lint-staged "*" glob invokes oxfmt on unsupported files (e.g. .gitignore, LICENSE, images), causing oxfmt to exit 2 and blocking the commit.

Fix on Vercel

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.

2 participants