将 Biome 与你的 VCS 集成
VCS(版本控制系统)集成旨在利用只有 VCS 才能提供的附加功能。目前,Biome 仅支持 Git。集成是可选的。你必须在 Biome 配置文件中启用 vcs.enabled 并设置 vcs.clientKind:
¥The VCS (Version Control System) integration is meant to take advantage of additional features that only a VCS can provide.
At the moment, Biome only supports Git.
The integration is opt-in.
You have to enable vcs.enabled and set vcs.clientKind in the Biome configuration file:
{ "vcs": { "enabled": true, "clientKind": "git" }}此配置本身不执行任何操作。你需要选择所需的功能。
¥This configuration doesn’t do anything per se. You need to opt-in the features you want.
使用忽略文件
Section titled “使用忽略文件”¥Use the ignore file
启用 vcs.useIgnoreFile,允许 Biome 忽略项目版本控制系统 (VCS) 忽略文件以及 .ignore 文件中列出的所有文件和目录。
¥Enable vcs.useIgnoreFile, to allow Biome to ignore all the files and directories listed in the project’s VCS ignore file as well as a .ignore file.
{ "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }}仅处理已更改的文件
Section titled “仅处理已更改的文件”¥Process only changed files
此功能仅通过 CLI 提供,并且仅允许处理从一个修订版更改为另一个修订版的文件。
¥This is a feature that is available only via CLI, and allows processing only the files that have changed from one revision to another.
首先,你必须更新配置文件并通过 vcs.defaultBranch 字段告诉 Biome 默认分支是什么:
¥First, you have to update your configuration file and tell Biome what’s the default branch via the vcs.defaultBranch field:
{ "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true, "defaultBranch": "main" }}然后,将 --changed 选项添加到你的命令中,以仅处理你的 VCS 确认为 “changed” 的那些文件。Biome 在 VCS 的帮助下,将从分支 main 和当前修订版中确定已更改的文件:
¥Then, add the --changed option to your command, to process only those files that your VCS acknowledged as “changed”. Biome, with the help of the VCS, will determine the changed file from the branch main and your current revision:
biome check --changed或者,你可以使用选项 --since 指定任意分支。此选项优先于选项 vcs.defaultBranch。例如,你可能希望根据 next 分支检查你的更改:
¥Alternatively, you can use the option --since to specify an arbitrary branch. This option takes precedence over the option vcs.defaultBranch. For example, you might want to check your changes against the next branch:
biome check --changed --since=next仅处理暂存文件
Section titled “仅处理暂存文件”¥Process only staged files
在提交更改之前,你可能需要检查添加到索引(也称为暂存文件)的文件的格式和代码检查,而无需对整个项目运行 Biome。要限制 Biome 仅处理计划提交的文件,请将 --staged 选项传递给命令:
¥Before committing your changes, you may want to check formatting and linting for files added to the index (also known as staged files) without running Biome on the entire project.
To limit Biome to only processing files slated for committing, pass the --staged option to the command:
biome check --stagedci 命令中不提供 --staged 选项,因为通常情况下,在持续集成 (CI) 期间你无需提交更改。
¥The --staged option is not available in the ci command, as you are usually not expected to commit changes during CI.
Biome v2.1 中文网 - 粤ICP备13048890号