biome-validator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Biome Validator

Biome 配置验证器

Validates Biome 2.3+ configuration and prevents outdated patterns. Ensures type-aware linting, domains, and modern Biome features are properly configured.
验证Biome 2.3+版本的配置并防止使用过时模式。确保类型感知代码检查、领域配置以及Biome的现代功能都已正确配置。

When This Activates

适用场景

  • Setting up linting for a new project
  • Before any code quality work
  • Auditing existing Biome configurations
  • After AI generates biome.json
  • CI/CD pipeline validation
  • 为新项目配置代码检查时
  • 进行任何代码质量工作之前
  • 审计现有Biome配置时
  • AI生成biome.json之后
  • CI/CD流水线验证环节

Quick Start

快速开始

bash
python3 ~/.claude/skills/biome-validator/scripts/validate.py --root .
python3 ~/.claude/skills/biome-validator/scripts/validate.py --root . --strict
bash
python3 ~/.claude/skills/biome-validator/scripts/validate.py --root .
python3 ~/.claude/skills/biome-validator/scripts/validate.py --root . --strict

What Gets Checked

检查内容

1. Biome Version & Schema

1. Biome版本与架构

GOOD - Biome 2.3+:
json
{
  "$schema": "https://biomejs.dev/schemas/2.3.12/schema.json"
}
BAD - Old schema:
json
{
  "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json"
}
符合要求 - Biome 2.3+版本:
json
{
  "$schema": "https://biomejs.dev/schemas/2.3.12/schema.json"
}
不符合要求 - 旧版架构:
json
{
  "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json"
}

2. Package Version

2. 包版本

json
// GOOD: v2.3+
"@biomejs/biome": "^2.3.0"

// BAD: v1.x or v2.0-2.2
"@biomejs/biome": "^1.9.0"
json
// 符合要求:v2.3+
"@biomejs/biome": "^2.3.0"

// 不符合要求:v1.x 或 v2.0-2.2版本
"@biomejs/biome": "^1.9.0"

3. Linter Configuration

3. 代码检查器配置

GOOD - Biome 2.x:
json
{
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "suspicious": {
        "noExplicitAny": "warn"
      }
    }
  }
}
符合要求 - Biome 2.x版本:
json
{
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "suspicious": {
        "noExplicitAny": "warn"
      }
    }
  }
}

4. Biome Assist (2.0+)

4. Biome辅助功能(2.0+)

GOOD - Using assist:
json
{
  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on"
      }
    }
  }
}
BAD - Old organizeImports location:
json
{
  "organizeImports": {
    "enabled": true
  }
}
符合要求 - 使用辅助功能:
json
{
  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on"
      }
    }
  }
}
不符合要求 - 旧版导入组织配置位置:
json
{
  "organizeImports": {
    "enabled": true
  }
}

5. Domains (2.0+)

5. 领域配置(2.0+)

GOOD - Using domains for framework-specific rules:
json
{
  "linter": {
    "domains": {
      "react": "on",
      "next": "on"
    }
  }
}
符合要求 - 为框架特定规则配置领域:
json
{
  "linter": {
    "domains": {
      "react": "on",
      "next": "on"
    }
  }
}

6. Suppression Comments

6. 抑制注释

GOOD - Biome 2.0+ comments:
typescript
// biome-ignore lint/suspicious/noExplicitAny: legacy code
// biome-ignore-all lint/style/useConst
// biome-ignore-start lint/complexity
// biome-ignore-end
BAD - Wrong format:
typescript
// @ts-ignore  // Not Biome
// eslint-disable  // Wrong tool
符合要求 - Biome 2.0+版本注释格式:
typescript
// biome-ignore lint/suspicious/noExplicitAny: legacy code
// biome-ignore-all lint/style/useConst
// biome-ignore-start lint/complexity
// biome-ignore-end
不符合要求 - 错误格式:
typescript
// @ts-ignore  // 非Biome格式
// eslint-disable  // 工具不匹配

Biome 2.3+ Features

Biome 2.3+版本特性

Type-Aware Linting

类型感知代码检查

Biome 2.0+ includes type inference without requiring TypeScript compiler:
json
{
  "linter": {
    "rules": {
      "correctness": {
        "noUndeclaredVariables": "error",
        "useAwaitThenable": "error"
      }
    }
  }
}
Biome 2.0+版本无需TypeScript编译器即可实现类型推断:
json
{
  "linter": {
    "rules": {
      "correctness": {
        "noUndeclaredVariables": "error",
        "useAwaitThenable": "error"
      }
    }
  }
}

Assist Actions

辅助操作

json
{
  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on",
        "useSortedKeys": "on"
      }
    }
  }
}
json
{
  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on",
        "useSortedKeys": "on"
      }
    }
  }
}

Multi-file Analysis

多文件分析

Lint rules can query information from other files for more powerful analysis.
代码检查规则可以查询其他文件的信息,实现更强大的分析功能。

Framework Domains

框架领域配置

json
{
  "linter": {
    "domains": {
      "react": "on",       // React-specific rules
      "next": "on",        // Next.js rules
      "test": "on"         // Testing framework rules
    }
  }
}
json
{
  "linter": {
    "domains": {
      "react": "on",       // React特定规则
      "next": "on",        // Next.js规则
      "test": "on"         // 测试框架规则
    }
  }
}

Recommended Configuration

推荐配置

json
{
  "$schema": "https://biomejs.dev/schemas/2.3.12/schema.json",
  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on"
      }
    }
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "complexity": {
        "noForEach": "off"
      },
      "style": {
        "noNonNullAssertion": "off"
      },
      "suspicious": {
        "noArrayIndexKey": "off",
        "noExplicitAny": "warn"
      },
      "correctness": {
        "useAwaitThenable": "error",
        "noLeakedRender": "error"
      }
    },
    "domains": {
      "react": "on",
      "next": "on"
    }
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 100
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingCommas": "es5",
      "semicolons": "always"
    }
  },
  "files": {
    "ignore": [
      "node_modules",
      "dist",
      "build",
      ".next",
      "out",
      ".cache",
      ".turbo",
      "coverage"
    ]
  }
}
json
{
  "$schema": "https://biomejs.dev/schemas/2.3.12/schema.json",
  "assist": {
    "actions": {
      "source": {
        "organizeImports": "on"
      }
    }
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "complexity": {
        "noForEach": "off"
      },
      "style": {
        "noNonNullAssertion": "off"
      },
      "suspicious": {
        "noArrayIndexKey": "off",
        "noExplicitAny": "warn"
      },
      "correctness": {
        "useAwaitThenable": "error",
        "noLeakedRender": "error"
      }
    },
    "domains": {
      "react": "on",
      "next": "on"
    }
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 100
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingCommas": "es5",
      "semicolons": "always"
    }
  },
  "files": {
    "ignore": [
      "node_modules",
      "dist",
      "build",
      ".next",
      "out",
      ".cache",
      ".turbo",
      "coverage"
    ]
  }
}

Deprecated Patterns

已弃用模式

DeprecatedReplacement (2.3+)
organizeImports.enabled
assist.actions.source.organizeImports
Schema < 2.0Schema 2.3.11+
@biomejs/biome
< 2.3
@biomejs/biome@latest
No domains configUse
linter.domains
for frameworks
已弃用内容替代方案(2.3+版本)
organizeImports.enabled
assist.actions.source.organizeImports
架构版本 < 2.0架构版本 2.3.11+
@biomejs/biome
版本 < 2.3
@biomejs/biome@latest
无领域配置使用
linter.domains
配置框架规则

Validation Output

验证输出示例

=== Biome 2.3+ Validation Report ===

Package Version: @biomejs/biome@2.3.11 ✓

Configuration:
  ✓ Schema version: 2.3.11
  ✓ Linter enabled with recommended rules
  ✓ Using assist.actions for imports
  ✗ No domains configured (consider enabling react, next)
  ✓ Formatter configured

Rules:
  ✓ noExplicitAny: warn
  ✓ useAwaitThenable: error
  ✗ noLeakedRender not enabled (recommended)

Summary: 2 issues found
=== Biome 2.3+ Validation Report ===

Package Version: @biomejs/biome@2.3.11 ✓

Configuration:
  ✓ Schema version: 2.3.11
  ✓ Linter enabled with recommended rules
  ✓ Using assist.actions for imports
  ✗ No domains configured (consider enabling react, next)
  ✓ Formatter configured

Rules:
  ✓ noExplicitAny: warn
  ✓ useAwaitThenable: error
  ✗ noLeakedRender not enabled (recommended)

Summary: 2 issues found

Migration from ESLint

从ESLint迁移

Step 1: Install Biome

步骤1:安装Biome

bash
bun remove eslint prettier eslint-config-* eslint-plugin-*
bun add -D @biomejs/biome@latest
bash
bun remove eslint prettier eslint-config-* eslint-plugin-*
bun add -D @biomejs/biome@latest

Step 2: Create biome.json

步骤2:创建biome.json配置文件

bash
bunx biome init
bash
bunx biome init

Step 3: Migrate rules

步骤3:迁移规则

bash
bunx biome migrate eslint --write
bash
bunx biome migrate eslint --write

Step 4: Update scripts

步骤4:更新脚本命令

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

Step 5: Remove old configs

步骤5:移除旧配置文件

bash
rm .eslintrc* .prettierrc* .eslintignore .prettierignore
bash
rm .eslintrc* .prettierrc* .eslintignore .prettierignore

VS Code Integration

VS Code集成

json
// .vscode/settings.json
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "biomejs.biome",
  "editor.codeActionsOnSave": {
    "source.organizeImports.biome": "explicit",
    "quickfix.biome": "explicit"
  }
}
json
// .vscode/settings.json
{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "biomejs.biome",
  "editor.codeActionsOnSave": {
    "source.organizeImports.biome": "explicit",
    "quickfix.biome": "explicit"
  }
}

CI/CD Integration

CI/CD集成

yaml
undefined
yaml
undefined

.github/workflows/lint.yml

.github/workflows/lint.yml

  • name: Validate Biome Config run: | python3 ~/.claude/skills/biome-validator/scripts/validate.py
    --root .
    --strict
    --ci
  • name: Lint run: bunx biome check --error-on-warnings .
undefined
  • name: Validate Biome Config run: | python3 ~/.claude/skills/biome-validator/scripts/validate.py
    --root .
    --strict
    --ci
  • name: Lint run: bunx biome check --error-on-warnings .
undefined

Integration

集成工具

  • linter-formatter-init
    - Sets up Biome from scratch
  • nextjs-validator
    - Validates Next.js (enable next domain)
  • bun-validator
    - Validates Bun workspace
  • linter-formatter-init
    - 从头开始配置Biome
  • nextjs-validator
    - 验证Next.js配置(需启用next领域)
  • bun-validator
    - 验证Bun工作区配置