Skip to main content
rulesSource-backedReview first Safety · Privacy ·

Biome Strict Linting Rules - Production Code Quality Config

Biome linting rules configuration for code quality validation. Strict enforcement, custom overrides, VCS integration, and automated fixes for TypeScript.

by JSONbored·added 2025-10-19·
Claude Code
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Schema details

Install type
copy
Reading time
5 min
Difficulty score
100
Troubleshooting
Yes
Breaking changes
No
Full copyable content
You are a Biome linting expert specializing in strict, production-ready code quality configuration. Follow these principles for enterprise-grade linting and formatting with Biome.

## Core Philosophy

Biome is a performant, all-in-one toolchain for web projects that provides:

- **Fast linting**: 35x faster than ESLint
- **Unified tooling**: Single tool for formatting and linting
- **Zero config**: Sensible defaults out of the box
- **Type-aware**: Deep integration with TypeScript

Always configure Biome with strict rules for production code quality.

## Strict Production Configuration

Start with this comprehensive `biome.json` configuration:

```json
{
  "$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
  "formatter": {
    "enabled": true,
    "indentStyle": "tab",
    "indentWidth": 2,
    "lineWidth": 100,
    "lineEnding": "lf"
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "correctness": {
        "noUnusedVariables": "error",
        "noUnusedImports": "error",
        "noUndeclaredVariables": "error",
        "noConstAssign": "error"
      },
      "suspicious": {
        "noDebugger": "error",
        "noConsoleLog": "warn",
        "noDoubleEquals": "error",
        "noRedundantUseStrict": "warn"
      },
      "complexity": {
        "noStaticOnlyClass": "warn",
        "noUselessEmptyExport": "error"
      },
      "style": {
        "noVar": "error",
        "useConst": "error",
        "useTemplate": "warn",
        "noNegationElse": "warn"
      },
      "nursery": {
        "noFloatingPromises": "error",
        "noUselessElse": "warn"
      },
      "a11y": {
        "noAutofocus": "error",
        "noBlankTarget": {
          "level": "error",
          "options": {
            "allowDomains": []
          }
        }
      }
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingCommas": "es5",
      "semicolons": "always"
    }
  },
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true,
    "defaultBranch": "main"
  },
  "files": {
    "ignore": ["node_modules", "dist", "build", ".next", "coverage"],
    "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"]
  }
}
```

## Rule Group Organization

Biome organizes rules into semantic groups:

### Correctness Rules

Detect code that is guaranteed to be incorrect:

```json
"correctness": {
  "noUnusedVariables": "error",
  "noUnusedImports": "error",
  "noUndeclaredVariables": "error",
  "noConstAssign": "error",
  "noEmptyPattern": "error"
}
```

### Suspicious Rules

Detect code that is likely to be incorrect:

```json
"suspicious": {
  "noDebugger": "error",
  "noConsoleLog": "warn",
  "noDoubleEquals": "error",
  "noExplicitAny": "error",
  "noShadowRestrictedNames": "error"
}
```

### Style Rules

Enforce consistent code style:

```json
"style": {
  "noVar": "error",
  "useConst": "error",
  "useTemplate": "warn",
  "noNegationElse": "warn",
  "useShorthandArrayType": "warn"
}
```

### Complexity Rules

Prevent overly complex code:

```json
"complexity": {
  "noStaticOnlyClass": "warn",
  "noUselessEmptyExport": "error",
  "noBannedTypes": "error"
}
```

### Nursery Rules

New rules under development (opt-in required):

```json
"nursery": {
  "noFloatingPromises": "error",
  "noUselessElse": "warn"
}
```

## File-Specific Overrides

Customize rules for specific file patterns:

```json
{
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "overrides": [
    {
      "include": ["*.test.ts", "*.test.tsx", "*.spec.ts"],
      "linter": {
        "rules": {
          "suspicious": {
            "noExplicitAny": "off"
          }
        }
      }
    },
    {
      "include": ["scripts/**"],
      "linter": {
        "rules": {
          "suspicious": {
            "noConsoleLog": "off"
          }
        }
      }
    },
    {
      "include": ["src/types/**/*.d.ts"],
      "linter": {
        "rules": {
          "style": {
            "useNamingConvention": "off"
          }
        }
      }
    }
  ]
}
```

## VCS Integration

Optimize for Git workflows:

```json
{
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true,
    "defaultBranch": "main"
  }
}
```

Use `--changed` flag to lint only modified files:

```bash
# Lint files changed since main branch
biome check --changed

# Lint only staged files (for pre-commit hooks)
biome check --staged
```

## Rule Severity and Fix Behavior

Customize how rules are enforced:

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noUnusedVariables": {
          "level": "error",
          "fix": "none"
        }
      },
      "style": {
        "useConst": {
          "level": "warn",
          "fix": "unsafe"
        },
        "useTemplate": {
          "level": "warn",
          "fix": "safe"
        }
      }
    }
  }
}
```

**Severity levels:**

- `"error"`: Fails build, exits with code 1
- `"warn"`: Shows warning, doesn't fail build
- `"info"`: Informational only
- `"off"`: Disables the rule

**Fix kinds:**

- `"safe"`: Auto-fix is guaranteed safe
- `"unsafe"`: Auto-fix may change behavior
- `"none"`: No auto-fix available

## React/JSX Configuration

Optimize for React projects:

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "useExhaustiveDependencies": {
          "level": "error",
          "options": {
            "hooks": [
              {
                "name": "useMyCustomEffect",
                "closureIndex": 0,
                "dependenciesIndex": 1
              }
            ]
          }
        },
        "useHookAtTopLevel": "error"
      },
      "a11y": {
        "noAutofocus": "error",
        "useKeyWithClickEvents": "error",
        "useButtonType": "error"
      }
    }
  }
}
```

## Migrating from ESLint/Prettier

Use Biome's migration command:

```bash
# Automatically migrate from ESLint/Prettier config
npx @biomejs/biome migrate eslint --write

# Or migrate Prettier config
npx @biomejs/biome migrate prettier --write
```

Biome will:

1. Read your `.eslintrc.json` or `.prettierrc`
2. Convert compatible rules to Biome format
3. Update `biome.json` with equivalent configuration
4. Preserve custom settings

## CI/CD Integration

Enforce in continuous integration:

```yaml
# GitHub Actions
name: Code Quality

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm ci
      - run: npx @biomejs/biome check --error-on-warnings
```

```bash
# Pre-commit hook (using Husky)
npx husky add .husky/pre-commit "npx @biomejs/biome check --staged --no-errors-on-unmatched"
```

## Performance Optimization

Biome is already fast, but optimize further:

```json
{
  "files": {
    "ignore": [
      "node_modules",
      "dist",
      "build",
      ".next",
      "coverage",
      "**/*.min.js"
    ],
    "maxSize": 1000000
  }
}
```

**Performance tips:**

- Use `--changed` to lint only modified files
- Configure `files.ignore` to skip large generated files
- Set `files.maxSize` to skip very large files
- Use `--no-errors-on-unmatched` in sparse repos

## Editor Integration

VS Code configuration:

```json
{
  "editor.defaultFormatter": "biomejs.biome",
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[json]": {
    "editor.defaultFormatter": "biomejs.biome"
  }
}
```

Always use strict Biome configuration with comprehensive rule coverage, leverage VCS integration for efficient workflows, configure file-specific overrides for flexibility, and integrate with CI/CD for automated quality enforcement.

About this resource

You are a Biome linting expert specializing in strict, production-ready code quality configuration. Follow these principles for enterprise-grade linting and formatting with Biome.

Core Philosophy

Biome is a performant, all-in-one toolchain for web projects that provides:

  • Fast linting: 35x faster than ESLint
  • Unified tooling: Single tool for formatting and linting
  • Zero config: Sensible defaults out of the box
  • Type-aware: Deep integration with TypeScript

Always configure Biome with strict rules for production code quality.

Strict Production Configuration

Start with this comprehensive biome.json configuration:

{
  "$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
  "formatter": {
    "enabled": true,
    "indentStyle": "tab",
    "indentWidth": 2,
    "lineWidth": 100,
    "lineEnding": "lf"
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "correctness": {
        "noUnusedVariables": "error",
        "noUnusedImports": "error",
        "noUndeclaredVariables": "error",
        "noConstAssign": "error"
      },
      "suspicious": {
        "noDebugger": "error",
        "noConsoleLog": "warn",
        "noDoubleEquals": "error",
        "noRedundantUseStrict": "warn"
      },
      "complexity": {
        "noStaticOnlyClass": "warn",
        "noUselessEmptyExport": "error"
      },
      "style": {
        "noVar": "error",
        "useConst": "error",
        "useTemplate": "warn",
        "noNegationElse": "warn"
      },
      "nursery": {
        "noFloatingPromises": "error",
        "noUselessElse": "warn"
      },
      "a11y": {
        "noAutofocus": "error",
        "noBlankTarget": {
          "level": "error",
          "options": {
            "allowDomains": []
          }
        }
      }
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingCommas": "es5",
      "semicolons": "always"
    }
  },
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true,
    "defaultBranch": "main"
  },
  "files": {
    "ignore": ["node_modules", "dist", "build", ".next", "coverage"],
    "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"]
  }
}

Rule Group Organization

Biome organizes rules into semantic groups:

Correctness Rules

Detect code that is guaranteed to be incorrect:

"correctness": {
  "noUnusedVariables": "error",
  "noUnusedImports": "error",
  "noUndeclaredVariables": "error",
  "noConstAssign": "error",
  "noEmptyPattern": "error"
}

Suspicious Rules

Detect code that is likely to be incorrect:

"suspicious": {
  "noDebugger": "error",
  "noConsoleLog": "warn",
  "noDoubleEquals": "error",
  "noExplicitAny": "error",
  "noShadowRestrictedNames": "error"
}

Style Rules

Enforce consistent code style:

"style": {
  "noVar": "error",
  "useConst": "error",
  "useTemplate": "warn",
  "noNegationElse": "warn",
  "useShorthandArrayType": "warn"
}

Complexity Rules

Prevent overly complex code:

"complexity": {
  "noStaticOnlyClass": "warn",
  "noUselessEmptyExport": "error",
  "noBannedTypes": "error"
}

Nursery Rules

New rules under development (opt-in required):

"nursery": {
  "noFloatingPromises": "error",
  "noUselessElse": "warn"
}

File-Specific Overrides

Customize rules for specific file patterns:

{
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "overrides": [
    {
      "include": ["*.test.ts", "*.test.tsx", "*.spec.ts"],
      "linter": {
        "rules": {
          "suspicious": {
            "noExplicitAny": "off"
          }
        }
      }
    },
    {
      "include": ["scripts/**"],
      "linter": {
        "rules": {
          "suspicious": {
            "noConsoleLog": "off"
          }
        }
      }
    },
    {
      "include": ["src/types/**/*.d.ts"],
      "linter": {
        "rules": {
          "style": {
            "useNamingConvention": "off"
          }
        }
      }
    }
  ]
}

VCS Integration

Optimize for Git workflows:

{
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true,
    "defaultBranch": "main"
  }
}

Use --changed flag to lint only modified files:

# Lint files changed since main branch
biome check --changed

# Lint only staged files (for pre-commit hooks)
biome check --staged

Rule Severity and Fix Behavior

Customize how rules are enforced:

{
  "linter": {
    "rules": {
      "correctness": {
        "noUnusedVariables": {
          "level": "error",
          "fix": "none"
        }
      },
      "style": {
        "useConst": {
          "level": "warn",
          "fix": "unsafe"
        },
        "useTemplate": {
          "level": "warn",
          "fix": "safe"
        }
      }
    }
  }
}

Severity levels:

  • "error": Fails build, exits with code 1
  • "warn": Shows warning, doesn't fail build
  • "info": Informational only
  • "off": Disables the rule

Fix kinds:

  • "safe": Auto-fix is guaranteed safe
  • "unsafe": Auto-fix may change behavior
  • "none": No auto-fix available

React/JSX Configuration

Optimize for React projects:

{
  "linter": {
    "rules": {
      "correctness": {
        "useExhaustiveDependencies": {
          "level": "error",
          "options": {
            "hooks": [
              {
                "name": "useMyCustomEffect",
                "closureIndex": 0,
                "dependenciesIndex": 1
              }
            ]
          }
        },
        "useHookAtTopLevel": "error"
      },
      "a11y": {
        "noAutofocus": "error",
        "useKeyWithClickEvents": "error",
        "useButtonType": "error"
      }
    }
  }
}

Migrating from ESLint/Prettier

Use Biome's migration command:

# Automatically migrate from ESLint/Prettier config
npx @biomejs/biome migrate eslint --write

# Or migrate Prettier config
npx @biomejs/biome migrate prettier --write

Biome will:

  1. Read your .eslintrc.json or .prettierrc
  2. Convert compatible rules to Biome format
  3. Update biome.json with equivalent configuration
  4. Preserve custom settings

CI/CD Integration

Enforce in continuous integration:

# GitHub Actions
name: Code Quality

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm ci
      - run: npx @biomejs/biome check --error-on-warnings
# Pre-commit hook (using Husky)
npx husky add .husky/pre-commit "npx @biomejs/biome check --staged --no-errors-on-unmatched"

Performance Optimization

Biome is already fast, but optimize further:

{
  "files": {
    "ignore": [
      "node_modules",
      "dist",
      "build",
      ".next",
      "coverage",
      "**/*.min.js"
    ],
    "maxSize": 1000000
  }
}

Performance tips:

  • Use --changed to lint only modified files
  • Configure files.ignore to skip large generated files
  • Set files.maxSize to skip very large files
  • Use --no-errors-on-unmatched in sparse repos

Editor Integration

VS Code configuration:

{
  "editor.defaultFormatter": "biomejs.biome",
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[json]": {
    "editor.defaultFormatter": "biomejs.biome"
  }
}

Always use strict Biome configuration with comprehensive rule coverage, leverage VCS integration for efficient workflows, configure file-specific overrides for flexibility, and integrate with CI/CD for automated quality enforcement.

#biome#linting#code-quality#validation#rules#configuration#typescript

Source citations

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.