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. Provide the overrides property inside biome config to support .astro files:

    biome.json
    {
    "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
    "organizeImports": {
    "enabled": true
    },
    "linter": {
    "enabled": true,
    "rules": {
    "recommended": true
    }
    },
    "overrides": [
    {
    "include": ["*.astro"],
    "linter": {
    "rules": {
    "style": {
    "useConst": "off",
    "useImportType": "off"
    }
    }
    }
    }
    ]
    }
  4. Run Biome’s CLI to lint & format your project’s files:

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

Adding package.json script

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

package.json
{
"scripts": {
"lint": "biome lint --write .",
"lint:fix": "biome check --write ." // lints, formats and organizes imports
}
}