Vercel

Biome

Learn how to use Biome in your Turborepo projects.

Set up Biome in a Turborepo

Set up Biome for formatting and linting in this Turborepo. 1) Install Biome 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.

Biome is a fast formatter for JavaScript, TypeScript, JSX, and JSON that saves CI and developer time.

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

Using Biome with Turborepo

Biome is a rare exception to most tools that are used with Turborepo because it is so extraordinarily fast. For this reason, we recommend using a Root Task rather than creating separate scripts in each of your packages.

Caching behavior

Using Biome at the root of the project will result in cache misses for all tasks when you upgrade Biome versions or change configuration. If you prefer the tradeoff of higher cache hit ratios in these situations over less configuration, you can still use Biome in separate scripts like the other recommendations in our guides.

Initialize Biome

First, follow the installation documentation to set up Biome in your repository. You'll then be able to create a script to use Biome in the root of your repository:

./package.json
{
  "scripts": {
    "format-and-lint": "biome check .",
    "format-and-lint:fix": "biome check . --write"
  }
}

Create a root task

In practice, Biome is unlikely to be a bottleneck in the iteration speed of your repository. For this reason, we can have less configuration to manage in our repository by using Biome in a Root Task.

If you believe Biome may be faster in your repository split up into tasks in packages, you are free to do so. We encourage you to experiment with what's best for your use case.

To create a Root Task, register the scripts to Turborepo:

./turbo.json
{
  "tasks": {
    "//#format-and-lint": {},
    "//#format-and-lint:fix": {
      "cache": false
    }
  }
}

You'll now be able to run these scripts using turbo run format-and-lint and turbo run format-and-lint:fix.