Setting up Biome
Quickly configure Biome for your Astro project
-
Install Biome using your preferred package manager:
Terminal window npm install --save-dev --save-exact @biomejs/biomeTerminal window pnpm add --save-dev --save-exact @biomejs/biomeTerminal window yarn add --dev --exact @biomejs/biomeTerminal window bun add --dev --exact @biomejs/biome -
Next, create the Biome configuration:
Terminal window npx @biomejs/biome initTerminal window pnpm biome initTerminal window yarn biome initTerminal window bunx biome initTerminal window deno run -A npm:@biomejs/biome init -
Enable full
.astroHTML support and theastrolinter domain inbiome.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"}}} -
Run Biome’s CLI to lint & format your project’s files:
Terminal window npx @biomejs/biome check --write .Terminal window pnpm biome check --write .Terminal window yarn biome check --write .Terminal window bunx biome check --write .Terminal window deno run -A npm:@biomejs/biome check --write .
Adding package.json scripts
Section titled “Adding package.json scripts”You can use Biome CLI with your preferred package manager by adding the following scripts in package.json of your project’s directory:
{ "scripts": { "lint": "biome check .", "lint:fix": "biome check --write ." }}