biome
Fast linting/formatting for TypeScript/React. Use when setting up linter, migrating from ESLint/Prettier, or running code quality checks.
What this skill does
# Biome
## Overview
Biome is a fast Rust-based toolchain that combines formatting, linting, and import organization. **25x faster than Prettier**, **15x faster than ESLint**. Replaces ESLint + Prettier with single tool.
**Key features (v2.0)**:
- 97% Prettier compatibility, 340+ lint rules
- Type-aware linting without TypeScript compiler
- Supports: JS, TS, JSX, TSX, JSON, CSS, GraphQL
- Framework domains: react, next, solid, test
## When to Use This Skill
- Setting up linting/formatting for new project
- Migrating from ESLint + Prettier
- Configuring pre-commit hooks
- Setting up CI code quality checks
- Configuring monorepo linting
## Instructions
### 1. Installation
```bash
# npm/pnpm/yarn
npm install --save-dev --save-exact @biomejs/biome
npx @biomejs/biome init
# Bun
bun add -D -E @biomejs/biome
bunx @biomejs/biome init
```
### 2. Configuration (biome.json)
**Recommended for React/TypeScript:**
```json
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"domains": {
"react": "recommended"
},
"correctness": {
"noUnusedVariables": "error"
},
"nursery": {
"noFloatingPromises": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "all",
"semicolons": "always"
}
},
"organizeImports": {
"enabled": true
},
"files": {
"ignore": ["node_modules", "dist", "build", ".next", "coverage"]
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
```
### 3. Package.json Scripts
```json
{
"scripts": {
"check": "biome check .",
"check:fix": "biome check --write .",
"lint": "biome lint .",
"lint:fix": "biome lint --write .",
"format": "biome format --write .",
"ci": "biome ci ."
}
}
```
### 4. Commands
```bash
# Check all (lint + format + imports) - recommended
npx @biomejs/biome check --write
# CI mode (fails on issues, no auto-fix)
npx @biomejs/biome ci
# Format only
npx @biomejs/biome format --write .
# Lint only
npx @biomejs/biome lint --write .
```
## Migration from ESLint/Prettier
```bash
# Auto-migrate configs
npx @biomejs/biome migrate eslint --write
npx @biomejs/biome migrate prettier --write
```
**Manual steps:**
1. Run migration commands
2. Review generated `biome.json`
3. Delete: `.eslintrc.*`, `.prettierrc.*`, `.eslintignore`, `.prettierignore`
4. Remove ESLint/Prettier from `package.json`
5. Update pre-commit hooks and CI
## Biome v2 Features
### Domains
Enable framework-specific rules automatically:
```json
{
"linter": {
"rules": {
"domains": {
"react": "recommended",
"next": "recommended",
"test": "all"
}
}
}
}
```
Biome auto-detects from `package.json` dependencies.
### Type Inference (Biotype)
Type-aware linting without TypeScript compiler (~85% coverage):
```json
{
"linter": {
"rules": {
"nursery": {
"noFloatingPromises": "error"
}
}
}
}
```
### Multi-file Analysis
```json
{
"linter": {
"rules": {
"nursery": {
"noImportCycles": "error",
"noPrivateImports": "error"
}
}
}
}
```
### Suppressions
```typescript
// Single line
// biome-ignore lint/suspicious/noExplicitAny: legacy code
const data: any = fetchData();
// Entire file
// biome-ignore-all lint/suspicious/noExplicitAny
// Range
// biome-ignore-start lint/style/noVar
var legacy = "code";
// biome-ignore-end
```
## Monorepo Setup
**Root config:**
```json
{
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"formatter": { "indentStyle": "space", "indentWidth": 2 },
"linter": { "rules": { "recommended": true } }
}
```
**Package config (`packages/web/biome.json`):**
```json
{
"root": false,
"extends": "//",
"linter": {
"rules": {
"domains": { "react": "recommended" }
}
}
}
```
## Pre-commit Hooks
### Lefthook (Recommended)
```bash
npm install -D lefthook
npx lefthook install
```
**lefthook.yml:**
```yaml
pre-commit:
commands:
biome:
run: npx @biomejs/biome check --write --no-errors-on-unmatched --files-ignore-unknown=true {staged_files}
stage_fixed: true
```
### Husky + lint-staged
```json
{
"lint-staged": {
"*.{js,ts,jsx,tsx,json,css}": ["biome check --write --no-errors-on-unmatched"]
}
}
```
## VS Code Integration
Install: [Biome VS Code Extension](https://marketplace.visualstudio.com/items?itemName=biomejs.biome)
**.vscode/settings.json:**
```json
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"biome.enabled": true,
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit",
"source.fixAll.biome": "explicit"
}
}
```
## CI (GitHub Actions)
```yaml
name: Code Quality
on: [push, pull_request]
jobs:
biome:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: biomejs/setup-biome@v2
- run: biome ci --changed
```
## Quick Reference
| Task | Command |
|------|---------|
| Check all + fix | `biome check --write .` |
| CI mode | `biome ci .` |
| Lint only | `biome lint .` |
| Format only | `biome format --write .` |
| Migrate ESLint | `biome migrate eslint --write` |
| Migrate Prettier | `biome migrate prettier --write` |
## Guidelines
### Do
- Use `biome check --write` as primary command (lint + format + imports)
- Commit `biome.json` to repo
- Use `--changed` in CI for speed
- Enable relevant domains (react, next, test)
- Use `--no-errors-on-unmatched` in hooks
### Don't
- Mix Biome with ESLint/Prettier in same project
- Forget to remove old linter configs after migration
- Skip `--write` flag when you want auto-fix
- Ignore `nursery` rules - they have useful type-aware checks
## Limitations
| Limitation | Workaround |
|------------|------------|
| JSON-only config | Use `extends` for shared configs |
| Vue/Svelte/Astro | Partial support (improving) |
| YAML/Markdown | Not supported |
| Some ESLint plugins | Check rule compatibility |
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.