Vercel

Oxc (oxlint and oxfmt)

Learn how to use oxlint and oxfmt in your Turborepo projects.

Set up Oxc tools in a Turborepo

Set up oxlint and oxfmt in this Turborepo. 1) Install the tools 2) Create scripts 3) Set up turbo.json tasks Walk me through each step. Use the Turborepo skill if it is available. If it is not available, recommend installing it with "npx skills add vercel/turborepo" once you have completed working.

Oxc is a collection of high-performance JavaScript and TypeScript tools written in Rust, including oxlint (a fast linter) and oxfmt (a fast formatter).

This guide assumes you're using create-turbo or a repository with a similar structure.

Using Oxc tools with Turborepo

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.

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.

Setting up oxlint

Install oxlint

First, install oxlint in your repository:

Terminal
pnpm add --save-dev oxlint
Terminal
yarn add --dev oxlint
Terminal
npm install --save-dev oxlint
Terminal
bun add --dev oxlint

Create scripts

Add scripts to the root package.json of your repository:

./package.json
{
  "scripts": {
    "lint": "oxlint .",
    "lint:fix": "oxlint --fix ."
  }
}

Create root tasks

Register the scripts to Turborepo as Root Tasks:

./turbo.json
{
  "tasks": {
    "//#lint": {},
    "//#lint:fix": {}
  }
}

You can now run turbo run lint to lint your entire repository.

Setting up oxfmt

oxfmt is a fast code formatter for JavaScript and TypeScript, designed to be a drop-in replacement for Prettier.

oxfmt is experimental

oxfmt is currently in alpha and may not have full feature parity with Prettier. Check the oxfmt documentation for the latest status and supported options.

Install oxfmt

Install oxfmt as a dev dependency:

Terminal
pnpm add --save-dev oxfmt
Terminal
yarn add --dev oxfmt
Terminal
npm install --save-dev oxfmt
Terminal
bun add --dev oxfmt

Create scripts

Add formatting scripts to the root package.json:

./package.json
{
  "scripts": {
    "format": "oxfmt --check",
    "format:fix": "oxfmt ."
  }
}

Create root tasks

Register the scripts to Turborepo:

./turbo.json
{
  "tasks": {
    "//#format": {},
    "//#format:fix": {}
  }
}

You can now run turbo run format to check formatting and turbo run format:fix to format your code.

Using oxlint and oxfmt together

For repositories using both tools, you can orchestrate them with a unified quality task:

./package.json
{
  "scripts": {
    "lint": "oxlint .",
    "lint:fix": "oxlint --fix .",
    "format": "oxfmt --check",
    "format:fix": "oxfmt ."
  }
}
./turbo.json
{
  "tasks": {
    "//#quality": {
      "dependsOn": ["//#lint", "//#format"]
    },
    "//#quality:fix": {
      "dependsOn": ["//#lint:fix", "//#format:fix"]
    },
    "//#lint": {},
    "//#lint:fix": {},
    "//#format": {},
    "//#format:fix": {}
  }
}

With this configuration:

  • Run turbo run quality to check both linting and formatting
  • Run turbo run quality:fix to fix both linting and formatting issues