Skip to content

Runbook: native Bun formatting and linting

Run the package scripts from a shell using the repository’s mise toolchain:

Terminal window
mise exec -- bun run format
mise exec -- bun run lint

Both commands check without changing source files. format:write and lint:fix are the mutating equivalents. Use package scripts for a narrower check, for example:

Terminal window
mise exec -- bun run --cwd packages/offline-data lint

The scripts call bun fmt --no-script and bun lint --no-script --type-aware. The latter flag keeps type-aware rules enabled; Bun supplies the checker itself. --no-script prevents the native command from resolving back to a package script with the same name. Shell scripts still use ShellCheck through lint:shell.

Mise and the CI validation job select canary for native type-aware lint. Stable Bun 1.4.5 resolves bun lint to the workspace’s own lint script, which calls it recursively. The 1.4.5 source gates native lint on canary.

Integration, conformance and browser CI jobs use stable 1.4.5 from the root packageManager pin. The agent-tools image builder reads the same pin. The Argo build, application runtime and conformance containers use the matching image tag. To check the local executable:

Terminal window
mise which bun
mise exec -- bun --revision

When the installed canary revision changes, the mise selector still reads canary. Force fresh quality checks so Turbo runs them with the new binary:

Terminal window
mise exec -- bun run lint --force
mise exec -- bun run format --force

Bun reads .oxlintrc.jsonc and .oxfmtrc.jsonc directly. Keeping these files preserves the existing rule set and formatting style, including import sorting and package script sorting. It also preserves the test overrides, warnings-as-errors policy, unused-disable reporting, and the custom pgxsinkit/guarded-query-purity JavaScript rule. There is no ESLint configuration or ESLint CLI in this setup.

Keep all existing exclusions: immutable ADRs, committed migration snapshots, conformance and enrichment capture fixtures, generated route trees and i18n files, and vendored upstream source. Do not run a broad formatting write to migrate the toolchain. Quality checks should not rewrite teaching materials or generator-owned files.

The diagnostic commands below inspect the configuration without linting or formatting files:

Terminal window
mise exec -- bun lint --no-script --doctor
mise exec -- bun fmt --no-script --doctor

The lint report should show no configured rules left unrun. The pgxsinkit rule runs in JavaScript; built-in rules, including type-aware rules, run natively.

The current Bun commands have no language server. Keep oxfmt, oxlint and oxlint-tsgolint as editor-only dependencies for the existing Oxc VS Code integration. The Oxc extension uses the project-local formatter and linter; type-aware editor checks also require oxlint-tsgolint. The repository’s quality scripts and CI execute Bun, not these binaries. The official Bun extension currently does not replace these formatting and lint providers.

See the official lint migration guide, format migration guide, and Oxc editor configuration.

Teacher-portal test scripts use Bun’s --isolate mode. Each file gets fresh globals and module records, including the DOM preload. The suites use file-specific module mocks and browser storage spies; sharing those across files on the 1.4.5 canary caused provider-context failures and lost saved storage state. Isolation preserves the real component assertions and the coverage gate.

Offline-data tests keep two parallel files and an explicit 30-second per-test timeout, matching the API and teacher test allowance. Their real pgwasm startup can exceed Bun’s five-second default when coverage runs alongside other suites. This is execution headroom; assertions and concurrency remain unchanged.

On a workstation also hosting the local cluster, simultaneous API/DB coverage shards can still push expensive real-policy checks past their allowance. If those tests pass in isolation, run the heavy package tasks separately, then let the normal gate reuse their task results:

Terminal window
mise exec -- bun run test:coverage --filter=@emergent/db
mise exec -- bun run test:coverage --filter=@emergent/api
mise exec -- bun run validate

These are the same coverage tasks and assertions; the filters separate their execution. Keep one validation active at a time.

If the invoking shell sets HTTP_PROXY/HTTPS_PROXY, include 127.0.0.1,localhost in NO_PROXY (and no_proxy where required) for the local HTTP test servers. Without the loopback exception, the MCP client can receive a proxy 502 before the request reaches its test server. This is an invocation environment setting, not an MCP handler failure; keep any existing non-loopback proxy exceptions as well.

For a tooling-only migration, run formatting and linting checks first. Coordinate with the maintainer before launching a full validation while another commit or validation is running. Running duplicate gates both consumes resources and makes timing comparisons unreliable.