Skip to content

[Due for payment 2026-07-13] Replace Prettier with Oxfmt and setup a pre-commit hook to run formatting #95240

Description

@roryabraham

Proposal: Replace Prettier with Oxfmt and setup a pre-commit hook to run formatting

Background

We currently use Prettier for JS and TS code formatting. We also use @prettier/plugin-oxc to speed up prettier by using the oxidation compiler under the hood. Prettier runs on E/App typically take ~30s.

Problem

When we open a pull request without running all CI checks locally, if Prettier fails, then we waste time and money on CI checks that fail and delay pull requests unnecessarily.

Solution

  1. Switch from Prettier to Oxfmt. Oxfmt is a 100% compatible* drop-in replacement for Prettier. A clean run of Oxfmt in E/App takes ~0.7s (~38x faster than prettier).
  2. Using lefthook, set up a pre-commit hook that runs Oxfmt and includes the formatting in the diff.

This solves the problem because it'll be no longer possible to commit unformatted JS/TS code in E/App. The switch to Oxfmt is included because it makes formatting fast enough that it's only a barely-noticable delay in commits.

Notes for completeness:

  • lefthook can be bypassed if necessary with LEFTHOOK=0 or the --no-verify flag for git commit
  • Oxfmt is 100% compatible with Prettier, and has its own import sorting built-in. But it's import sorting isn't 100% the same as @trivago/prettier-plugin-sort-imports. So the PR to enable it has a large diff, but that diff is only reordering imports.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions