npx skills add https://github.com/paulrberg/agent-skills --skill biome-js基于 Sablier 项目模式的 BiomeJS 配置快速指南。
通过 npm 包导出扩展共享配置。使用项目必须始终提供自己的 files.includes:
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@sablier/devkit/biome"],
"files": {
"includes": ["**/*.{js,json,jsonc,ts}", "!node_modules/**/*"]
}
}
对于 UI 项目,同时扩展基础配置和 UI 配置:
{
"extends": ["@sablier/devkit/biome/base", "@sablier/devkit/biome/ui"],
"files": {
"includes": ["**/*.{css,js,jsx,json,jsonc,ts,tsx}"]
}
}
在单体仓库中,工作区配置使用 "//" 从根配置继承:
// packages/my-package/biome.jsonc
{
"extends": ["//"],
"overrides": [
// 包特定的覆盖配置
]
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
始终明确指定 files.includes。常见模式:
| 项目类型 | 模式 |
|---|---|
| 库 | **/*.{js,json,jsonc,ts} |
| UI/前端 | **/*.{css,js,jsx,json,jsonc,ts,tsx} |
| 包含 GraphQL | **/*.{css,graphql,js,jsx,json,jsonc,ts,tsx} |
排除项:!node_modules/**/*、!**/generated、!dist
在测试文件中放宽严格规则:
{
"overrides": [
{
"includes": ["**/tests/**/*.ts", "**/*.test.ts"],
"linter": {
"rules": {
"style": {
"noNonNullAssertion": "off"
},
"suspicious": {
"noExplicitAny": "off"
}
}
}
}
]
}
对生成的代码禁用排序和紧凑格式化:
{
"overrides": [
{
"includes": ["**/abi/**/*.ts", "**/generated/**/*.ts"],
"assist": {
"actions": {
"source": {
"useSortedKeys": "off"
}
}
},
"javascript": {
"formatter": {
"expand": "never"
}
}
}
]
}
对特定模块强制使用桶导入:
{
"overrides": [
{
"includes": ["src/**/*.{ts,tsx}"],
"linter": {
"rules": {
"correctness": {
"noRestrictedImports": {
"level": "error",
"options": {
"paths": {
"@/core": "请从 @/core(桶)导入,而不是子路径"
}
}
}
}
}
}
}
]
}
| 规则 | 默认值 | 原理 |
|---|---|---|
noFloatingPromises | error | 未处理的 Promise 会导致错误 |
noUnusedImports | off | 开发期间允许,提交前强制执行 |
noUnusedVariables | error | 保持代码整洁 |
useImportType | warn (separatedType) | 显式类型导入 |
useSortedKeys | on | 一致的对象排序 |
useSortedClasses | warn (UI) | Tailwind 类排序 |
useFilenamingConvention | kebab/camel/Pascal | 灵活的命名规则 |
noVoid | off | 对 useEffect 回调有用 |
useTemplate | off | 允许字符串拼接 |
提交前钩子的标准模式:
// .lintstagedrc.js
module.exports = {
"*.{json,jsonc,ts,tsx}": "bun biome check --write",
"*.{md,yml,yaml}": "bun prettier --cache --write",
"*.{ts,tsx}": "bun biome check --write --only=correctness/noUnusedImports",
};
单独的 noUnusedImports 检查确保仅在提交时强制执行导入清理,而不是在开发期间。
对于使用 Tailwind CSS 的前端项目:
{
"css": {
"parser": {
"tailwindDirectives": true
}
},
"assist": {
"actions": {
"source": {
"useSortedAttributes": "on"
}
}
},
"linter": {
"rules": {
"nursery": {
"useSortedClasses": {
"fix": "safe",
"level": "warn",
"options": {
"attributes": ["classList"],
"functions": ["clsx", "cva", "cn", "tv", "tw"]
}
}
}
}
}
}
Biome v2.4.0+ 自动为 *.module.css 启用 CSS 模块解析,因此通常不需要显式的 "cssModules": true,除非您的项目需要非标准行为。
biome check 和 biome ci 现在支持 --only 和 --skip 用于针对特定规则/操作的运行。biome check --write 现在在应用修复时也会应用格式化。.biome.json 和 .biome.jsonc。$HOME/.config/biome)。formatter.trailingNewline 可以禁用尾随换行符插入。v2.4.0 中发生了显著变化;如果启用了格式化器支持,请预期 HTML/Vue/Svelte/Astro 文件中会有较大的差异。"没有匹配的文件":检查 files.includes 模式是否与您的文件结构匹配。
规则冲突:覆盖配置按顺序应用;后面的覆盖配置具有优先权。
模式错误:使用本地模式引用以获得 IDE 支持:
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json"
Biome 处理 JS/TS/JSON/CSS 格式化。使用 Prettier 处理:
.md, .mdx).yml, .yaml)./examples/ 中的工作示例:
./examples/base-config.jsonc - 最小库配置./examples/ui-config.jsonc - 使用 Tailwind 的前端项目./examples/lint-staged.js - 提交前钩子配置对于高级功能、迁移或完整的规则参考,请通过 Context7 MCP 查阅官方 Biome 文档:
Use context7 to fetch Biome documentation for [specific topic]
对于本文档未涵盖的功能,应查阅 biomejs.dev 上的官方文档作为最后手段。
每周安装量
120
代码仓库
GitHub 星标数
41
首次出现
2026年2月5日
安全审计
已安装于
claude-code109
codex101
opencode98
gemini-cli97
github-copilot96
amp96
Quick guidance for BiomeJS configuration based on Sablier project patterns.
Extend shared configs via npm package exports. The consuming project must always provide its own files.includes:
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@sablier/devkit/biome"],
"files": {
"includes": ["**/*.{js,json,jsonc,ts}", "!node_modules/**/*"]
}
}
For UI projects, extend both base and ui configs:
{
"extends": ["@sablier/devkit/biome/base", "@sablier/devkit/biome/ui"],
"files": {
"includes": ["**/*.{css,js,jsx,json,jsonc,ts,tsx}"]
}
}
In monorepos, workspace configs inherit from root using "//":
// packages/my-package/biome.jsonc
{
"extends": ["//"],
"overrides": [
// package-specific overrides
]
}
Always specify files.includes explicitly. Common patterns:
| Project Type | Pattern |
|---|---|
| Library | **/*.{js,json,jsonc,ts} |
| UI/Frontend | **/*.{css,js,jsx,json,jsonc,ts,tsx} |
| With GraphQL | **/*.{css,graphql,js,jsx,json,jsonc,ts,tsx} |
Exclusions: !node_modules/**/*, !**/generated, !dist
Relax strict rules in test files:
{
"overrides": [
{
"includes": ["**/tests/**/*.ts", "**/*.test.ts"],
"linter": {
"rules": {
"style": {
"noNonNullAssertion": "off"
},
"suspicious": {
"noExplicitAny": "off"
}
}
}
}
]
}
Disable sorting and compact formatting for generated code:
{
"overrides": [
{
"includes": ["**/abi/**/*.ts", "**/generated/**/*.ts"],
"assist": {
"actions": {
"source": {
"useSortedKeys": "off"
}
}
},
"javascript": {
"formatter": {
"expand": "never"
}
}
}
]
}
Enforce barrel imports for specific modules:
{
"overrides": [
{
"includes": ["src/**/*.{ts,tsx}"],
"linter": {
"rules": {
"correctness": {
"noRestrictedImports": {
"level": "error",
"options": {
"paths": {
"@/core": "Import from @/core (barrel) instead of subpaths"
}
}
}
}
}
}
}
]
}
| Rule | Default | Rationale |
|---|---|---|
noFloatingPromises | error | Floating promises cause bugs |
noUnusedImports | off | Allow during dev, enforce in pre-commit |
noUnusedVariables | error | Keep code clean |
useImportType | warn (separatedType) | Explicit type imports |
useSortedKeys | on |
Standard pattern for pre-commit hooks:
// .lintstagedrc.js
module.exports = {
"*.{json,jsonc,ts,tsx}": "bun biome check --write",
"*.{md,yml,yaml}": "bun prettier --cache --write",
"*.{ts,tsx}": "bun biome check --write --only=correctness/noUnusedImports",
};
The separate noUnusedImports pass enforces import cleanup only at commit time, not during development.
For frontend projects with Tailwind CSS:
{
"css": {
"parser": {
"tailwindDirectives": true
}
},
"assist": {
"actions": {
"source": {
"useSortedAttributes": "on"
}
}
},
"linter": {
"rules": {
"nursery": {
"useSortedClasses": {
"fix": "safe",
"level": "warn",
"options": {
"attributes": ["classList"],
"functions": ["clsx", "cva", "cn", "tv", "tw"]
}
}
}
}
}
}
Biome v2.4.0+ auto-enables CSS Modules parsing for *.module.css, so explicit "cssModules": true is usually unnecessary unless your project needs non-standard behavior.
biome check and biome ci now support --only and --skip for targeted rule/action runs.biome check --write now also applies formatting when applying fixes..biome.json and .biome.jsonc.$HOME/.config/biome on Linux/macOS equivalents).formatter.trailingNewline can disable trailing newline insertion.v2.4.0; expect larger diffs in HTML/Vue/Svelte/Astro if formatter support is enabled."No files matched" : Check files.includes patterns match your file structure.
Conflicting rules : Overrides are applied in order; later overrides take precedence.
Schema errors : Use local schema reference for IDE support:
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json"
Biome handles JS/TS/JSON/CSS formatting. Use Prettier for:
.md, .mdx).yml, .yaml)Working examples in ./examples/:
./examples/base-config.jsonc - Minimal library configuration./examples/ui-config.jsonc - Frontend project with Tailwind./examples/lint-staged.js - Pre-commit hook configurationFor advanced features, migrations, or complete rule reference, consult the official Biome documentation via Context7 MCP:
Use context7 to fetch Biome documentation for [specific topic]
The official docs at biomejs.dev should be consulted as a last resort for features not covered here.
Weekly Installs
120
Repository
GitHub Stars
41
First Seen
Feb 5, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code109
codex101
opencode98
gemini-cli97
github-copilot96
amp96
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
45,200 周安装
| Consistent object ordering |
useSortedClasses | warn (UI) | Tailwind class sorting |
useFilenamingConvention | kebab/camel/Pascal | Flexible naming |
noVoid | off | Useful for useEffect callbacks |
useTemplate | off | Allow string concatenation |