用途:帮助团队为 JavaScript、TypeScript、JSON、CSS 等语言建立一致的代码风格,用 Biome 的格式化器统一格式并提供检查能力。
主要能力:提供基础格式化命令(biome format --write .)、只检查不修改(biome format .)、标准输入格式化(配合 --stdin-file-path)、lint 与 format 合并的 biome check --write 以及 CI 模式 biome ci .。可通过 biome.json 配置全局选项:enabled、formatWithErrors、indentStyle、indentWidth、lineEnding、lineWidth、attributePosition;语言级选项包括 quoteStyle、jsxQuoteStyle、quoteProperties、trailingCommas、semicolons、arrowParentheses、bracketSpacing、bracketSameLine,并分别支持 JSON(trailingCommas 固定 none)与 CSS(quoteStyle 等)。可给出 Prettier-like、Standard/XO、Google、Airbnb 等风格示例配置,支持 // biome-ignore format 忽略块、formatter.ignore 与 files.ignore 忽略文件、overrides 覆盖,以及 --changed、--since 只格式化变更文件。
使用方式:安装 npm install -D @biomejs/biome,运行 npx biome init 生成配置,再执行 npx biome format --write .;可在 package.json 添加 format、format:check 脚本,并在 VS Code 设置 editor.defaultFormatter 为 biomejs.biome、开启 formatOnSave。迁移自 Prettier 时对照其配置并卸载 prettier。
适用场景:项目格式化标准建立、团队风格统一、Prettier 迁移、CI/CD 中检查格式、monorepo 共享配置与编辑器集成。
限制:仅覆盖资料中列出的命令与配置项;具体版本、性能数据、框架支持范围及收费情况暂未提供。