重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
biome-linting by thebushidocollective/han
npx skills add https://github.com/thebushidocollective/han --skill biome-linting深入了解 Biome 的代码检查功能、规则类别,以及针对 JavaScript 和 TypeScript 项目的代码质量强制执行。
Biome 的检查器提供快速、全面的代码质量检查,重点关注正确性、性能、安全性和最佳实践。它旨在捕获常见错误并强制执行一致的代码模式。
# 检查文件但不修复
biome check .
# 检查并自动修复
biome check --write .
# 检查特定文件
biome check src/**/*.ts
# CI 模式(严格,警告即失败)
biome ci .
# 详细输出
biome check --verbose .
# JSON 输出
biome check --json .
# 仅检查(跳过格式化)
biome lint .
# 仅应用安全修复
biome check --write --unsafe=false .
针对 Web 可访问性和 WCAG 合规性的规则:
{
"linter": {
"rules": {
"a11y": {
"recommended": true,
"noAccessKey": "error",
"noAriaHiddenOnFocusable": "error",
"noAutofocus": "warn",
"noBlankTarget": "error",
"noPositiveTabindex": "error",
"useAltText": "error",
"useAnchorContent": "error",
"useButtonType": "error",
"useValidAriaProps": "error"
}
}
}
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
常见违规:
用于降低代码复杂度的规则:
{
"linter": {
"rules": {
"complexity": {
"recommended": true,
"noBannedTypes": "error",
"noExcessiveCognitiveComplexity": "warn",
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessConstructor": "error",
"noUselessEmptyExport": "error",
"noUselessFragments": "error",
"noUselessLabel": "error",
"noUselessRename": "error",
"noUselessSwitchCase": "error",
"noWith": "error"
}
}
}
}
针对代码正确性和错误预防的规则:
{
"linter": {
"rules": {
"correctness": {
"recommended": true,
"noChildrenProp": "error",
"noConstAssign": "error",
"noConstantCondition": "error",
"noConstructorReturn": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
}
}
}
}
关键规则:
noUndeclaredVariables:捕获未声明的变量noUnusedVariables:移除未使用的代码noConstAssign:防止 const 重新赋值noUnreachable:检测不可达的代码useIsNan:使用 isNaN() 进行 NaN 检查用于性能优化的规则:
{
"linter": {
"rules": {
"performance": {
"recommended": true,
"noAccumulatingSpread": "warn",
"noDelete": "error"
}
}
}
}
针对安全最佳实践的规则:
{
"linter": {
"rules": {
"security": {
"recommended": true,
"noDangerouslySetInnerHtml": "error",
"noDangerouslySetInnerHtmlWithChildren": "error",
"noGlobalEval": "error"
}
}
}
}
关键安全规则:
代码风格和一致性规则:
{
"linter": {
"rules": {
"style": {
"recommended": true,
"noArguments": "error",
"noCommaOperator": "error",
"noImplicitBoolean": "warn",
"noNegationElse": "warn",
"noNonNullAssertion": "warn",
"noParameterAssign": "error",
"noRestrictedGlobals": "error",
"noShoutyConstants": "warn",
"noUnusedTemplateLiteral": "error",
"noVar": "error",
"useBlockStatements": "warn",
"useCollapsedElseIf": "warn",
"useConst": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "warn",
"useExponentiationOperator": "error",
"useFragmentSyntax": "error",
"useNumericLiterals": "error",
"useSelfClosingElements": "error",
"useShorthandArrayType": "error",
"useSingleVarDeclarator": "error",
"useTemplate": "warn",
"useWhile": "error"
}
}
}
}
关键风格规则:
noVar:使用 let/const 替代 varuseConst:对于不可变绑定首选 constnoNonNullAssertion:避免在 TypeScript 中使用 ! 断言useTemplate:首选模板字面量针对可疑代码模式的规则:
{
"linter": {
"rules": {
"suspicious": {
"recommended": true,
"noArrayIndexKey": "warn",
"noAssignInExpressions": "error",
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCommentText": "error",
"noCompareNegZero": "error",
"noConsoleLog": "warn",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDoubleEquals": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "warn",
"noExplicitAny": "warn",
"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noLabelVar": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noSelfCompare": "error",
"noShadowRestrictedNames": "error",
"noUnsafeNegation": "error",
"useDefaultSwitchClauseLast": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
}
}
}
关键可疑模式:
noExplicitAny:避免在 TypeScript 中使用 anynoConsoleLog:在生产环境中移除 console.lognoDebugger:移除 debugger 语句noDoubleEquals:使用 === 替代 ==noDuplicateObjectKeys:捕获重复的键针对高质量代码库的最大严格度:
{
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": { "recommended": true },
"complexity": { "recommended": true },
"correctness": { "recommended": true },
"performance": { "recommended": true },
"security": { "recommended": true },
"style": { "recommended": true },
"suspicious": {
"recommended": true,
"noExplicitAny": "error",
"noConsoleLog": "error"
}
}
}
}
从宽松开始,逐步收紧:
{
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn",
"noConsoleLog": "warn"
},
"style": {
"noVar": "error",
"useConst": "warn"
}
}
}
}
React 配置示例:
{
"linter": {
"rules": {
"recommended": true,
"a11y": { "recommended": true },
"correctness": {
"recommended": true,
"noChildrenProp": "error"
},
"security": {
"noDangerouslySetInnerHtml": "error"
},
"suspicious": {
"noArrayIndexKey": "error"
}
}
}
}
抑制特定违规:
// biome-ignore lint/suspicious/noExplicitAny: 遗留代码
function legacyFunction(data: any) {
return data;
}
// biome-ignore lint/suspicious/noConsoleLog: 调试日志
console.log('Debug info');
// 多个规则
// biome-ignore lint/suspicious/noExplicitAny lint/style/useConst: 迁移中
var config: any = {};
忽略整个文件:
/* biome-ignore-file */
// 遗留文件,跳过所有检查
在 biome.json 中忽略模式:
{
"files": {
"ignore": [
"**/generated/**",
"**/*.config.js",
"**/vendor/**"
]
}
}
"recommended": true 开始biome ci为组织创建共享规则集:
{
"extends": ["@company/biome-config"],
"linter": {
"rules": {
"suspicious": {
"noConsoleLog": "error"
}
}
}
}
对不同代码区域使用覆盖配置:
{
"overrides": [
{
"include": ["src/**/*.ts"],
"linter": {
"rules": {
"suspicious": {
"noExplicitAny": "error"
}
}
}
},
{
"include": ["scripts/**/*.js"],
"linter": {
"rules": {
"suspicious": {
"noConsoleLog": "off"
}
}
}
}
]
}
从 ESLint 迁移:
npm install -D @biomejs/biomenpx biome initnpx biome check . 查看违规情况npx biome check --write .{
"scripts": {
"lint": "biome check .",
"lint:fix": "biome check --write .",
"lint:ci": "biome ci ."
}
}
使用 husky:
{
"husky": {
"hooks": {
"pre-commit": "biome check --write --changed"
}
}
}
- name: Run Biome
run: npx biome ci .
如果规则错误触发:
如果检查速度慢:
验证:
每周安装次数
54
仓库
GitHub 星标数
128
首次出现
2026年1月22日
安全审计
安装于
codex49
opencode48
gemini-cli46
cursor43
github-copilot42
claude-code38
Expert knowledge of Biome's linting capabilities, rule categories, and code quality enforcement for JavaScript and TypeScript projects.
Biome's linter provides fast, comprehensive code quality checks with a focus on correctness, performance, security, and best practices. It's designed to catch common bugs and enforce consistent code patterns.
# Check files without fixing
biome check .
# Check and auto-fix
biome check --write .
# Check specific files
biome check src/**/*.ts
# CI mode (strict, fails on warnings)
biome ci .
# Verbose output
biome check --verbose .
# JSON output
biome check --json .
# Only lint (skip formatting)
biome lint .
# Apply safe fixes only
biome check --write --unsafe=false .
Rules for web accessibility and WCAG compliance:
{
"linter": {
"rules": {
"a11y": {
"recommended": true,
"noAccessKey": "error",
"noAriaHiddenOnFocusable": "error",
"noAutofocus": "warn",
"noBlankTarget": "error",
"noPositiveTabindex": "error",
"useAltText": "error",
"useAnchorContent": "error",
"useButtonType": "error",
"useValidAriaProps": "error"
}
}
}
}
Common violations:
Rules to reduce code complexity:
{
"linter": {
"rules": {
"complexity": {
"recommended": true,
"noBannedTypes": "error",
"noExcessiveCognitiveComplexity": "warn",
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessConstructor": "error",
"noUselessEmptyExport": "error",
"noUselessFragments": "error",
"noUselessLabel": "error",
"noUselessRename": "error",
"noUselessSwitchCase": "error",
"noWith": "error"
}
}
}
}
Rules for code correctness and bug prevention:
{
"linter": {
"rules": {
"correctness": {
"recommended": true,
"noChildrenProp": "error",
"noConstAssign": "error",
"noConstantCondition": "error",
"noConstructorReturn": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
}
}
}
}
Critical rules:
noUndeclaredVariables: Catch undeclared variablesnoUnusedVariables: Remove unused codenoConstAssign: Prevent const reassignmentnoUnreachable: Detect unreachable codeuseIsNan: Use isNaN() for NaN checksRules for performance optimization:
{
"linter": {
"rules": {
"performance": {
"recommended": true,
"noAccumulatingSpread": "warn",
"noDelete": "error"
}
}
}
}
Rules for security best practices:
{
"linter": {
"rules": {
"security": {
"recommended": true,
"noDangerouslySetInnerHtml": "error",
"noDangerouslySetInnerHtmlWithChildren": "error",
"noGlobalEval": "error"
}
}
}
}
Critical security rules:
Code style and consistency rules:
{
"linter": {
"rules": {
"style": {
"recommended": true,
"noArguments": "error",
"noCommaOperator": "error",
"noImplicitBoolean": "warn",
"noNegationElse": "warn",
"noNonNullAssertion": "warn",
"noParameterAssign": "error",
"noRestrictedGlobals": "error",
"noShoutyConstants": "warn",
"noUnusedTemplateLiteral": "error",
"noVar": "error",
"useBlockStatements": "warn",
"useCollapsedElseIf": "warn",
"useConst": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "warn",
"useExponentiationOperator": "error",
"useFragmentSyntax": "error",
"useNumericLiterals": "error",
"useSelfClosingElements": "error",
"useShorthandArrayType": "error",
"useSingleVarDeclarator": "error",
"useTemplate": "warn",
"useWhile": "error"
}
}
}
}
Key style rules:
noVar: Use let/const instead of varuseConst: Prefer const for immutable bindingsnoNonNullAssertion: Avoid ! assertions in TypeScriptuseTemplate: Prefer template literalsRules for suspicious code patterns:
{
"linter": {
"rules": {
"suspicious": {
"recommended": true,
"noArrayIndexKey": "warn",
"noAssignInExpressions": "error",
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCommentText": "error",
"noCompareNegZero": "error",
"noConsoleLog": "warn",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDoubleEquals": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "warn",
"noExplicitAny": "warn",
"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noLabelVar": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noSelfCompare": "error",
"noShadowRestrictedNames": "error",
"noUnsafeNegation": "error",
"useDefaultSwitchClauseLast": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
}
}
}
Critical suspicious patterns:
noExplicitAny: Avoid any in TypeScriptnoConsoleLog: Remove console.log in productionnoDebugger: Remove debugger statementsnoDoubleEquals: Use === instead of ==noDuplicateObjectKeys: Catch duplicate keysMaximum strictness for high-quality codebases:
{
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": { "recommended": true },
"complexity": { "recommended": true },
"correctness": { "recommended": true },
"performance": { "recommended": true },
"security": { "recommended": true },
"style": { "recommended": true },
"suspicious": {
"recommended": true,
"noExplicitAny": "error",
"noConsoleLog": "error"
}
}
}
}
Start lenient and progressively tighten:
{
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn",
"noConsoleLog": "warn"
},
"style": {
"noVar": "error",
"useConst": "warn"
}
}
}
}
React configuration example:
{
"linter": {
"rules": {
"recommended": true,
"a11y": { "recommended": true },
"correctness": {
"recommended": true,
"noChildrenProp": "error"
},
"security": {
"noDangerouslySetInnerHtml": "error"
},
"suspicious": {
"noArrayIndexKey": "error"
}
}
}
}
Suppress specific violations:
// biome-ignore lint/suspicious/noExplicitAny: Legacy code
function legacyFunction(data: any) {
return data;
}
// biome-ignore lint/suspicious/noConsoleLog: Debug logging
console.log('Debug info');
// Multiple rules
// biome-ignore lint/suspicious/noExplicitAny lint/style/useConst: Migration
var config: any = {};
Ignore entire file:
/* biome-ignore-file */
// Legacy file, skip all linting
Ignore patterns in biome.json:
{
"files": {
"ignore": [
"**/generated/**",
"**/*.config.js",
"**/vendor/**"
]
}
}
"recommended": truebiome ci in pipelinesCreate shared rule sets for organization:
{
"extends": ["@company/biome-config"],
"linter": {
"rules": {
"suspicious": {
"noConsoleLog": "error"
}
}
}
}
Use overrides for different code areas:
{
"overrides": [
{
"include": ["src/**/*.ts"],
"linter": {
"rules": {
"suspicious": {
"noExplicitAny": "error"
}
}
}
},
{
"include": ["scripts/**/*.js"],
"linter": {
"rules": {
"suspicious": {
"noConsoleLog": "off"
}
}
}
}
]
}
Migrating from ESLint:
npm install -D @biomejs/biomenpx biome initnpx biome check . to see violationsnpx biome check --write .{
"scripts": {
"lint": "biome check .",
"lint:fix": "biome check --write .",
"lint:ci": "biome ci ."
}
}
Using husky:
{
"husky": {
"hooks": {
"pre-commit": "biome check --write --changed"
}
}
}
- name: Run Biome
run: npx biome ci .
If rule triggers incorrectly:
If linting is slow:
Verify:
Weekly Installs
54
Repository
GitHub Stars
128
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex49
opencode48
gemini-cli46
cursor43
github-copilot42
claude-code38
测试策略完整指南:单元/集成/E2E测试金字塔与自动化实践
11,200 周安装