apps/docs/content/docs/guides/tools/oxc.mdx
import { CreateTurboCallout } from "./create-turbo-callout.tsx";
Oxc is a collection of high-performance JavaScript and TypeScript tools written in Rust, including oxlint (a fast linter) and oxfmt (a fast formatter).
<CreateTurboCallout />Similar to Biome, oxlint and oxfmt are extraordinarily fast tools. For this reason, we recommend using Root Tasks rather than creating separate scripts in each of your packages.
<Callout type="info" title="Caching behavior"> Using oxlint or oxfmt at the root of the project will result in cache misses for all tasks when you upgrade versions or change configuration. If you prefer the tradeoff of higher cache hit ratios in these situations over less configuration, you can still run these tools in separate scripts like the other recommendations in our guides. </Callout>First, install oxlint in your repository:
<PackageManagerTabs> <Tab value="pnpm">pnpm add --save-dev -w oxlint
yarn add --dev oxlint
npm install --save-dev oxlint
bun add --dev oxlint
Add scripts to the root package.json of your repository:
{
"scripts": {
"lint": "oxlint .",
"lint:fix": "oxlint --fix ."
}
}
Register the scripts to Turborepo as Root Tasks:
{
"tasks": {
"//#lint": {},
"//#lint:fix": {
"cache": false
}
}
}
You can now run turbo run lint to lint your entire repository.
For example, to build Compiled Packages before running formatting and linting:
turbo run build --filter=./packages/* && turbo run lint
Alternatively, you can switch to per-package lint tasks with dependsOn: ["^build"] to let Turborepo handle the ordering for you.
oxfmt is a fast code formatter for JavaScript and TypeScript, designed to be a drop-in replacement for Prettier.
<Callout type="warn" title="oxfmt is experimental"> oxfmt is currently in alpha and may not have full feature parity with Prettier. Check the [oxfmt documentation](https://oxc.rs/docs/guide/usage/formatter) for the latest status and supported options. </Callout>Install oxfmt as a dev dependency:
<PackageManagerTabs> <Tab value="pnpm">pnpm add --save-dev -w oxfmt
yarn add --dev oxfmt
npm install --save-dev oxfmt
bun add --dev oxfmt
Add formatting scripts to the root package.json:
{
"scripts": {
"format": "oxfmt --check",
"format:fix": "oxfmt ."
}
}
Register the scripts to Turborepo:
{
"tasks": {
"//#format": {},
"//#format:fix": {
"cache": false
}
}
}
You can now run turbo run format to check formatting and turbo run format:fix to format your code.
For repositories using both tools, you can orchestrate them with a unified quality task:
{
"scripts": {
"lint": "oxlint .",
"lint:fix": "oxlint --fix .",
"format": "oxfmt --check",
"format:fix": "oxfmt ."
}
}
{
"tasks": {
"//#quality": {
"dependsOn": ["//#lint", "//#format"]
},
"//#quality:fix": {
"dependsOn": ["//#lint:fix", "//#format:fix"]
},
"//#lint": {},
"//#lint:fix": {
"cache": false
},
"//#format": {},
"//#format:fix": {
"dependsOn": ["//#lint:fix"],
"cache": false
}
}
}
With this configuration:
turbo run quality to check both linting and formatting in parallel (safe because neither modifies files)turbo run quality:fix to fix both linting and formatting issues, with formatting running after lint fixes to avoid file write race conditions