Add oxfmt formatter with auto-format PR workflow#4
Merged
Conversation
Set up oxfmt 0.52 as the project's formatter so contributor PRs cannot silently drift from the existing code style. Rules were tuned against PR #2, which contained large amounts of formatting noise (collapsed object literals re-expanded to multi-line, reordered imports) on top of real changes. - .oxfmtrc.json: 2-space, double quotes, semicolons, trailing commas, printWidth 100, objectWrap=collapse (defeats magic-trailing-comma expansion), sortImports=true (canonical import statement order). - package.json: format and format:check scripts; oxfmt devDependency. - AGENTS.md: documents the format commands and the no-hand-reformat rule. - .github/workflows/format-pr.yml: runs bun run format on every same-repo PR and pushes the result back as a github-actions[bot] commit. Gated on head.repo == github.repository because fork PRs only get a read-only GITHUB_TOKEN; fork contributors run format locally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Now that the project is open source, contributor PRs have been silently reformatting hand-written code (see #2, where the bulk of the diff was collapsed object literals being re-expanded to multi-line and reordered imports). This change locks in the existing style with a fast formatter and makes contributors' lives easier by running it for them in CI.
Approach
.oxfmtrc.json—oxfmt@0.52config tuned to the existing codebase: 2-space indent, double quotes, semicolons, trailing commas,printWidth: 100. Two non-default options matter:objectWrap: "collapse"— defeats Prettier-style magic-trailing-comma expansion, which was the dominant noise in feat(vm): add maxSteps execution budget #2.sortImports: true— keeps import statement order canonical.package.json— addsbun run formatandbun run format:check; addsoxfmtas a devDependency.AGENTS.md— documents the new commands and adds a "don't hand-reformat" rule for agents..github/workflows/format-pr.yml— runsbun run formaton every PR and pushes the result back as agithub-actions[bot]commit, so contributors never need to think about it.How the rules were validated
I diffed the base and head of #2, ran our formatter on both sides, then compared. Drop in noise per file:
src/boundary.tstest/interpreter-evaluator.test.tssrc/vm.tstest/vm.test.tsThe remaining diffs are genuine semantic changes, not formatting.
Things to know before merging
bun run format:checkonmainwill fail today (28 files need touching). Recommend runningbun run formatonmainas a single dedicated commit before this CI starts gating PRs, so future PRs only show real changes.head.repo == github.repository. Fork PRs only get a read-onlyGITHUB_TOKEN, so the push step would fail with 403. The alternatives (pull_request_targetwith PR-head checkout, or a PAT) are known pwn-request vectors and I did not want to opt into them silently. Fork contributors runbun run formatlocally. Happy to layer aformat:checkjob on top so they get a failing status — say the word.GITHUB_TOKENdo not trigger workflow runs (docs).{ VMError, VMErrorCode, createCapability }vs{ createCapability, VMError, VMErrorCode }). There's no oxfmt option for it; would need an ESLint rule layered on top.