入门指南
Biome 最好作为项目的开发依赖安装,但它也提供无需 Node.js 的 独立可执行文件 版本。
¥Biome is best installed as a development dependency of your projects, but it is also available as a standalone executable that doesn’t require Node.js.
npm i -D -E @biomejs/biomepnpm add -D -E @biomejs/biomebun add -D -E @biomejs/biomedeno add -D npm:@biomejs/biomeyarn add -D -E @biomejs/biome¥Configuration
虽然 Biome 可以零配置运行,但你可能需要根据项目需求调整一些设置。在这种情况下,你可以运行以下命令生成 biome.json 配置文件。
¥Although Biome can run with zero configuration, you’ll likely want to tweak some
settings to suit your project’s needs, in which case you can run the following
command to generate a biome.json configuration file.
npx @biomejs/biome initpnpm exec biome initbunx --bun biome initdeno run -A npm:@biomejs/biome inityarn exec biome init¥Usage
让我们快速了解一下如何在项目中使用 Biome。
¥Lets get a quick overview of how to use Biome in your project.
¥Command-line interface
Biome 提供了一个 命令行接口 来格式化、检查和检查你的代码。
¥Biome provides a command-line interface to format, lint, and check your code.
# Format all filesnpx @biomejs/biome format --write
# Format specific filesnpx @biomejs/biome format --write <files>
# Lint files and apply safe fixes to all filesnpx @biomejs/biome lint --write
# Lint files and apply safe fixes to specific filesnpx @biomejs/biome lint --write <files>
# Format, lint, and organize imports of all filesnpx @biomejs/biome check --write
# Format, lint, and organize imports of specific filesnpx @biomejs/biome check --write <files># Format all filespnpm exec biome format --write
# Format specific filespnpm exec biome format --write <files>
# Lint and apply safe fixes to all filespnpm exec biome lint --write
# Lint files and apply safe fixes to specific filespnpm exec biome lint --write <files>
# Format, lint, and organize imports of all filespnpm exec biome check --write
# Format, lint, and organize imports of specific filespnpm exec biome check --write <files># Format all filesbunx biome format --write
# Format specific filesbunx biome format --write <files>
# Lint and apply safe fixes to all filesbunx biome lint --write
# Lint files and apply safe fixes to specific filesbunx biome lint --write <files>
# Format, lint, and organize imports of all filesbunx biome check --write
# Format, lint, and organize imports of specific filesbunx biome check --write <files># Format specific filesdeno run -A npm:@biomejs/biome format --write <files>
# Format all filesdeno run -A npm:@biomejs/biome format --write
# Lint files and apply safe fixes to all filesdeno run -A npm:@biomejs/biome lint --write
# Lint files and apply safe fixes to specific filesdeno run -A npm:@biomejs/biome lint --write <files>
# Format, lint, and organize imports of all filesdeno run -A npm:@biomejs/biome check --write
# Format, lint, and organize imports of specific filesdeno run -A npm:@biomejs/biome check --write <files># Format all filesyarn exec biome format --write
# Format specific filesyarn exec biome format --write <files>
# Lint files and apply safe fixes to all filesyarn exec biome lint --write
# Lint files and apply safe fixes to specific filesyarn exec biome lint --write <files>
# Format, lint, and organize imports of all filesyarn exec biome check --write
# Format, lint, and organize imports of specific filesyarn exec biome check --write <files>¥Editor integrations
Biome 可作为你常用编辑器的官方扩展使用。
¥Biome is available as a first-party extension in your favorite editors.
社区扩展 也支持其他编辑器,例如 Vim、Neovim 和 Sublime Text 等。
¥There are also community extensions for other editors, such as Vim, Neovim, and Sublime Text, to name a few.
¥Continuous Integration
在你的 CI 流水线中运行 biome ci,以确保团队代码质量和一致性。它的工作方式与 biome check 命令完全相同,但针对 CI 环境进行了优化。
¥Run biome ci as part of your CI pipeline to enforce code quality and consistency
across your team. It works just like the biome check command, but is optimized for
CI environments.
请参阅 持续集成 示例以获取更多示例。
¥See the Continuous Integration recipes for more examples.
¥Next Steps
成功!你现在可以开始使用 Biome 了。🥳
¥Success! You’re now ready to use Biome. 🥳
-
了解有关如何使用 配置 Biome 的更多信息
¥Learn more about how to configure Biome
-
了解有关如何使用和配置 formatter 的更多信息
¥Learn more about how to use and configure the formatter
-
了解有关如何使用和配置 linter 的更多信息
¥Learn more about how to use and configure the linter
-
熟悉 CLI 命令和选项
¥Get familiar with the CLI commands and options
-
熟悉 配置选项
¥Get familiar with the configuration options
-
加入我们的 Discord 上的社区
¥Join our community on Discord
Biome v2.1 中文网 - 粤ICP备13048890号