Skip to content

Setting up Biome

Quickly configure Biome for your Astro project

  1. Install Biome using your preferred package manager:

    Terminal window
    npm install --save-dev --save-exact @biomejs/biome
  2. Next, create the Biome configuration:

    Terminal window
    npx @biomejs/biome init
  3. Enable full .astro HTML support and the astro linter domain in biome.json:

    biome.json
    {
    "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
    "html": {
    "experimentalFullSupportEnabled": true
    },
    "assist": {
    "actions": {
    "source": {
    "organizeImports": "on"
    }
    }
    },
    "linter": {
    "enabled": true,
    "domains": {
    "astro": "recommended"
    },
    "rules": {
    "preset": "recommended"
    }
    }
    }
  4. Run Biome’s CLI to lint & format your project’s files:

    Terminal window
    npx @biomejs/biome check --write .

You can use Biome CLI with your preferred package manager by adding the following scripts in package.json of your project’s directory:

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