Biome v2 - 代号:Biotype
我们很高兴地宣布 Biome v2 正式发布!🍾 Biome v2 - 代号:Biotype,首款提供类型感知代码检查规则且不依赖于 TypeScript 编译器的 JavaScript 和 TypeScript 代码检查器!这意味着你无需安装 typescript 包即可对项目进行代码检查。
¥We are happy to announce that Biome v2 is officially out! 🍾 Biome v2—codename: Biotype, the first JavaScript and TypeScript linter that provides
type-aware linting rules that doesn’t rely on the TypeScript compiler! This means that you can lint your project
without necessarily installing the typescript package.
通过此次发布,项目核心贡献者 希望向整个社区和 Web 生态系统表明,Biome 将继续存在,并有望成为下一代 Web 工具链。没有其他工具能在如此短的时间内(两年)和如此少的资源投入下实现这一重大里程碑。这要感谢相信该项目的公司和个人,特别感谢 Vercel 对类型推断工作的赞助。
¥With this release, the Core Contributors of the project want to show to the whole community and web ecosystem that Biome is here to stay and deserves to earn its place as the next-generation toolchain for the web. No other tools have achieved this great milestone in such a short amount of time (two years) and resources. This has been possible thanks to the companies and people who believed in the project, with a special shoutout to Vercel for sponsoring the type inference work.
初步测试表明,基于我们新的类型推断工作的 noFloatingPromises 规则,可以在大约 75% 的情况下检测到浮动 Promise,而性能影响仅为 typescript-eslint 的一小部分。毋庸置疑,我们有很多想法可以进一步改进这个指标。
¥Preliminary testing shows that our noFloatingPromises rule, which is based on our new type inference work, can detect floating promises in about 75% of the cases that would be detected by using typescript-eslint, at a fraction of the performance impact. And needless to say, we have plenty of ideas on how to improve this metric even further.
请记住,实际效果可能因用例而异,因为这些早期数据基于有限的用例集。尽管如此,我们期待用户试用并反馈他们的体验,以便我们能够尽快达到足以满足大多数项目需求的可靠性水平。
¥Keep in mind that your mileage may vary, as these early numbers are based on a limited set of use cases. Nevertheless, we look forward to people trying it out and reporting their experiences so that we can quickly reach a level of confidence that would be sufficient for most projects.
¥Installation and migration
安装或更新 @biomejs/biome 包。如果你升级了软件包,请运行 migrate 命令。
¥Install or update the @biomejs/biome package. If you upgrade the package, run the migrate command.
npm install --save-dev --save-exact @biomejs/biomenpx @biomejs/biome migrate --writemigrate 命令将处理所有配置中的破坏性更改,因此你无需手动操作。还有一些其他更改我们无法自动化。我们创建了一个 迁移指南 文档来解释这些内容,以及适用的手动迁移路径。请适应这些变化,因为其中一些变化从根本上改变了 Biome 的一些核心功能(而且是朝着更好的方向发展!)。
¥The migrate command will take care of all the breaking changes of the configuration, so you don’t have to. However, there are
some other changes that we couldn’t automate. We created a migration guide that explains them,
together with manual migration paths, if applicable. Please get accustomed to the changes, as some of them fundamentally
change some of the core functionalities of Biome (for the better!).
¥Relevant features
Biome 包含众多新功能,既有重要的,也有细微的。我们将专注于……我们认为值得一提的几点:有关新功能的完整列表,请参阅 更新日志网页版。
¥Biome is packed with new features, some big and some small. We will focus on the ones that we believe are worth mentioning. For a complete list of the new features, refer to the web version of the changelog.
多文件分析和类型推断
Section titled “多文件分析和类型推断”¥Multi-file analysis and type inference
这两个功能密切相关。如果没有查询从其他模块导入的类型的能力,你就无法创建类型推断引擎。
¥These two features are closely related. You can’t create a type inference engine without the ability to query types imported from other modules.
在 2.0 版本之前,Biome lint 规则一次只能处理一个文件。这让我们取得了很大进展,但许多更有趣的规则还需要来自其他文件的信息。
¥Before version 2.0, Biome lint rules could only operate on one file at a time. This brought us far, but many of the more interesting rules require information from other files too.
为此,我们在 Biome 中添加了一个文件扫描器,它会扫描项目中的所有文件并对其进行索引,类似于 IDE 中的 LSP 服务。
¥To accomplish this, we have added a file scanner to Biome that scans all the files in your project and indexes them, similar to what an LSP service might do in your IDE.
文件扫描器有一些特性:速度慢。我们知道很多用户选择 Biome 是因为它的速度。在 Beta 测试期间,用户提出了一些关于这可能会如何影响其工作流程的担忧。
¥A file scanner comes with its baggage: slowness. We acknowledge that many users choose Biome for its speed. During the beta period, users raised some concerns about how this could affect their workflow.
此版本的文件扫描器具有以下特性:
¥As for this release, the file scanner has the following characteristics:
-
可选;这意味着从 v1 迁移到 v2 不会显著影响项目格式化和代码检查的性能。
¥It’s opt-in; which means migrating from v1 to v2 won’t significantly affect the performance of formatting and linting your projects.
-
默认情况下,扫描器仅用于发现嵌套的配置文件。速度应该会非常快,但与 v1 相比可能会略有提升。
¥By default, the scanner is only used for discovering nested configuration files. This should be very fast, although a slight increase compared to v1 may be experienced.
-
仅当启用 项目规则 时,才会执行完整扫描(扫描所有项目文件和
node_modules)。¥A full scan (which scans all your project files and
node_modules) is performed only when project rules are enabled. -
用户可以使用
files.includes控制扫描的文件,但node_modules除外。¥Users can control the scanned files using
files.includes, with the exception ofnode_modules. -
需要收集类型信息或查询模块图的 Lint 规则,在
project域 之外将不被推荐使用。我们优先考虑速度和性能,用户可以控制规则。¥Lint rules that need to collect types or query the module graph will never be recommended outside the
projectdomain. We put speed and performance first, and users have control over the rules.
Monorepo 支持
Section titled “Monorepo 支持”¥Monorepo Support
我们显著改进了对单体仓库 (monorepo) 的支持。这意味着,依赖于 package.json 文件信息的 lint 规则现在将使用来自正确包的 package.json。但或许更重要的是:现在,我们支持嵌套配置文件。
¥We’ve significantly improved our support for monorepos. This means that lint rules that rely on information from package.json files will now use the package.json from the right package. But perhaps more importantly: We now support nested configuration files.
每个项目根目录下仍应有一个 biome.json 或 biome.jsonc,类似于 Biome v1。项目允许在子目录中包含任意数量的嵌套 biome.json/biome.jsonc 文件。嵌套配置文件必须通过以下两种方式之一显式标记。
¥Every project should still have a single biome.json or biome.jsonc at its root, similar to Biome v1. But projects are allowed to have any number of nested biome.json/biome.jsonc files in subdirectories. Nested configuration files must be explicitly marked as such, in one of two ways.
第一段代码如下所示:
¥The first looks like this:
{ "root": false, // ...}将 root 字段设置为 false,即可告知 Biome 这是一个嵌套文件。这一点很重要,因为如果你在嵌套文件夹内运行 Biome,它将知道该配置是更大项目的一部分,并会继续查找根配置。
¥By setting the root field to false, you tell Biome this is a nested file. This is important, because if you run Biome inside the nested folder, it will know that the configuration is part of a bigger project and continue looking for the root configuration as well.
需要强调的是,嵌套文件夹中的设置默认情况下不会继承根设置。如果你想从其他配置扩展,我们仍然希望你使用 Biome v1 中已有的 extends 字段。
¥It is important to stress that the settings within the nested folder do not inherit from the root settings by default. Rather, we still want you to use the extends field that already existed in Biome v1 if you want to extend from another configuration.
这就引出了嵌套配置的第二种定义方式:
¥Which brings us to the second way a nested configuration can be defined:
{ "extends": "//", // ...}这是一种便捷的微语法,它将 root 字段设置为 false,并告知 Biome 此嵌套配置继承自根配置。
¥This is a convenient micro-syntax that sets both the root field to false, and will tell Biome that this nested configuration extends from the root configuration.
告别诸如 "extends": ["../../biome.json"] 之类的奇怪相对路径。 👋
¥Say goodbye to wonky relative paths such as "extends": ["../../biome.json"] 👋
我们准备了一份 简易指南 文件,可以帮助你完成所有设置。
¥We prepared a small guide that should help you set everything up.
¥Plugins
Biome 2.0 包含我们第一个版本的 代码检查插件。
¥Biome 2.0 comes with our first iteration of Linter Plugins.
这些插件的功能仍然有限:它们只允许你匹配代码片段并报告其诊断信息。
¥These plugins are still limited in scope: They only allow you to match code snippets and report diagnostics on them.
以下是一个插件示例,用于报告所有 Object.assign() 的使用情况:
¥Here is an example of a plugin that reports on all usages of Object.assign():
`$fn($args)` where { $fn <: `Object.assign`, register_diagnostic( span = $fn, message = "Prefer object spread instead of `Object.assign()`" )}这只是第一步,但我们有很多想法来增强它们的功能,我们也渴望听到用户的意见,了解他们希望优先考虑哪些功能。
¥It’s a first step, but we have plenty of ideas for making them more powerful, and we’re eager to hear from our users about what they would like to see prioritised.
目前,出于各种原因,我们特意省略了插件的分发方式。然而,我们期待你的反馈。请使用 加入讨论 并与我们分享你的想法。
¥As for now, we intentionally left out the distribution method of plugin for different reasons. However, we would like to hear from you. Please join the discussion and share your ideas with us.
导入管理器改进
Section titled “导入管理器改进”¥Import Organizer Revamp
在 Biome 1.x 中,我们的导入管理器存在一些限制:
¥In Biome 1.x, our Import Organizer had several limitations:
-
以空行分隔的导入分组将被视为独立的数据块,这意味着它们将独立排序。这意味着以下操作未按预期运行:
¥Groups of imports separated by a blank line were considered separate chunks, meaning they were sorted independently. This meant the following didn’t work as expected:
example.js import { lib2 } from "library2";import { util } from "./utils.js";import { lib1 } from "library1";它可以正确地将
"library1"排序到"./utils.js"的上方,但无法将其移到换行符的顶部。以下是我们得到的结果:¥It would correctly sort
"library1"to be placed above"./utils.js", but it wouldn’t be able to carry it over the blank line to the top. This is what we got:organizer_v1.js import { lib2 } from "library2";import { lib1 } from "library1";import { util } from "./utils.js";但我们真正想要的是:
¥But instead, what we really wanted was this:
organizer_v2.js import { lib1 } from "library1";import { lib2 } from "library2";import { util } from "./utils.js"; -
来自同一模块的导入不会被合并。请看以下示例:
¥Imports from the same module were not merged. Consider the following example:
example.js import { util1 } from "./utils.js";import { util2 } from "./utils.js";我们想要的是这样的:
¥What we wanted was this:
organizer_v2.js import { util1, util2 } from "./utils.js"; -
无法配置自定义排序。或许你不太喜欢默认的按 “distance” 从源文件排序的方式。或许你希望像这样组织导入:
¥No custom ordering could be configured. Perhaps you didn’t really like the default approach of ordering by “distance” from the source that you’re importing from. Perhaps you wanted to organise the imports like this:
organizer_v2.js import { open } from "node:fs";import { internalLib1 } from "@company/library1";import { internalLib2 } from "@company/library2";import { lib1 } from "library1";
在 Biome 2.0 中,所有这些限制都已解除。实际上,如果你查看上面的示例,所有标记为 organizer_v2.js 的代码片段都可以由我们新的导入管理器轻松生成。
¥In Biome 2.0, all these limitations are lifted. In fact, if you look at the examples above, all snippets labeled organizer_v2.js can be produced just like that by our new import organizer.
其他改进包括支持组织 export 语句、支持使用 “detached” 注释在必要时显式分隔导入块,以及导入属性排序。
¥Other improvements include support for organizing export statements, support for “detached” comments to explicitly separate import chunks if necessary, and import attribute sorting.
你可以在 操作文档 中找到更多信息。
¥You can find more in the documentation of the action.
¥Assists
导入管理器在 Biome 中一直是一个比较特殊的功能。它既不是代码检查器的一部分,也不是格式化程序的一部分。这是因为我们不希望它像代码检查器那样显示诊断信息,而且它的组织功能超出了我们对格式化程序的预期。
¥The Import Organizer has always been a bit of a special case in Biome. It was neither part of the linter, nor of the formatter. This was because we didn’t want it to show diagnostics like the linter does, and its organizing features exceeded what we expect from the formatter.
在 Biome 2.0 中,我们以 Biome Assist 的形式对这些用例进行了通用化处理。Assist 提供的操作类似于 lint 规则中的修复,但不包含诊断信息。
¥In Biome 2.0, we have generalised such use cases in the form of Biome Assist. Assist provides actions, which are similar to the fixes in lint rules, but without the diagnostics.
导入管理器已升级为辅助功能,但我们也开始对其他辅助功能采用这种方法:useSortedKeys 可以对对象字面量中的键进行排序,而 useSortedAttributes 可以对 JSX 中的属性进行排序。
¥The Import Organizer has become an assist, but we’ve started using this approach for new assists too: useSortedKeys can sort keys in object literals, while useSortedAttributes can sort attributes in JSX.
有关辅助功能的更多信息,请参阅 相关页面。
¥For more information about assists, see the relative page.
¥Improved suppressions
除了我们之前支持的 // biome-ignore 注释之外,现在我们还支持 // biome-ignore-all,用于禁止对整个文件执行 lint 规则或格式化程序。
¥In addition to the // biome-ignore comments we already supported, we now support // biome-ignore-all for suppressing a lint rule or the formatter in an entire file.
我们还添加了对使用 // biome-ignore-start 和 // biome-ignore-end 设置抑制范围的支持。请注意,如果你希望范围运行到文件末尾,则 // biome-ignore-end 是可选的。
¥We also added support for suppression ranges using // biome-ignore-start and // biome-ignore-end. Note that // biome-ignore-end is optional in case you want to let a range run until the end of the file.
有关抑制功能的更多信息,请参阅 相关页面。
¥For more information about suppressions, see the relative page.
HTML 格式化程序
Section titled “HTML 格式化程序”¥HTML formatter
经过几个月的努力,我们很高兴地宣布 HTML 格式化程序现已准备就绪,供用户试用并报告错误!这是 Biome 向全面支持 Vue 和 Svelte 等框架中使用的类 HTML 模板语言迈出的重要一步。
¥After several months of hard work, we are pleased to announce that the HTML formatter is now ready for users to try out and report bugs! This is a huge step towards Biome fully supporting HTML-ish templating languages used in frameworks such as Vue and Svelte.
目前,HTML 格式化程序仅处理实际的 .html 文件,因此尚不支持格式化 .vue 或 .svelte 文件中的 HTML。目前它还不支持格式化嵌入式语言,例如 JavaScript 或 CSS。HTML 的选项,例如 attributePosition、bracketSameLine 和 whitespaceSensitivity,已经实现。
¥For now, the HTML formatter only touches actual .html files, so it doesn’t format HTML in .vue or .svelte files yet. It also won’t format embedded languages like JavaScript or CSS yet. HTML’s options like attributePosition, bracketSameLine, and whitespaceSensitivity have been implemented.
HTML 格式化程序仍处于实验阶段,因此在正式版 2.0 中默认禁用。截至撰写本文时,Biome 可以解析 Prettier 的大部分 HTML 测试套件,并正确格式化其中 124 个测试中的 46 个。尽管目前还不能完全匹配 Prettier,但我们相当有信心它能够输出格式正确的文档,且不会破坏任何内容。如果你发现任何不适用的情况,请 请告知我们!
¥The HTML formatter is still in the experimental stage, so it will remain disabled by default for the full 2.0 release. At the time of writing, Biome can parse most of the Prettier’s HTML test suite, and format 46/124 of them correctly. Despite not matching Prettier yet, we’re pretty confident that it should output adequately formatted documents without destroying anything. If you find a case where it doesn’t, please let us know!
你可以通过在配置文件中添加以下内容来启用 HTML 格式化程序:
¥You can enable the HTML formatter by adding the following to your config file:
{ "html": { "formatter": { "enabled": true } }}¥Shout-outs
现在,让我们对贡献者表示感谢!
¥And now, let’s give credits where credits are due!

特别感谢我们的白金赞助商 Vercel,以及由 Core Contributor
@arendjr 领导的 赞助类型推断工作。
¥Special thanks to Vercel, our platinum sponsor, for sponsoring the type inference work, led by Core Contributor
@arendjr .
特别感谢我们的黄金赞助商 Depot,为本项目提供强大而快速的 CI 运行器。大幅节省时间并提高可靠性!
¥Special thanks to Depot, our gold sponsor, for providing the project with powerful and fast CI runners. A huge time saver and reliability booster!
祝贺 Core Contributor
@siketyan 近期成为项目的核心贡献者!感谢他们的贡献,JetBrains 扩展 现已稳定并支持多个工作区。
¥Congratulations to Core Contributor
@siketyan , who recently became a Core Contributor of the project! Thanks to their contributions,
the JetBrains extension is now stable and supports multiple workspaces.
感谢 Core Contributor
@conaclos 为实现众多功能所做的巨大努力,例如导入管理器的改进、新的 glob 引擎以及许多新的代码检查规则。
¥Thanks to Core Contributor
@conaclos for their massive work in implementing many features such as the Import Organizer revamping,
the new glob engine, many new linting rules.
感谢 Core Contributor
@arendjr 创建了多文件架构,并持续改进了类型推断、插件以及其他各种功能。
¥Thanks to Core Contributor
@arendjr for creating the multi-file architecture, the continuous work on the type inference, plugins, and miscellaneous improvements.
感谢 Core Contributor
@nhedger 编写了 GitHub 操作,感谢 shipping 编写了 VS Code 扩展 的新版本。
¥Props to Core Contributor
@nhedger for authoring the GitHub Action, and shipping the new version of the VS Code extension.
感谢 Core Contributor
@dyc3 领导了 HTML 解析器和格式化器的工作。它们都是非常复杂的软件,尤其是在与 Prettier 的格式化体验相匹配方面。
¥Thanks to Core Contributor
@dyc3 for leading the work on the HTML parser and formatter. They are both very complex pieces of software, especially when it comes to matching Prettier’s formatting experience.
最后,还要特别感谢所有其他以 sponsors 和 contributors 开头的键!
¥Last but not least, a great thanks to all our other sponsors and contributors as well!
下一步是什么?
Section titled “下一步是什么?”¥What’s next
任何软件都难免存在 bug,因此我们会确保修复所有 bug 并发布补丁。
¥No software is exempt from bugs, so we will ensure that we squash them and release patches.
核心贡献者 将致力于推进 2025 年路线图 的发展,并重点关注以下特性:
¥The Core Contributors will focus on moving forward the Roadmap for 2025, and focus on the following features:
-
稳定 HTML 支持。
¥Make HTML support stable.
-
扩展 HTML 以支持其他框架,例如 Vue、Svelte 和 Astro。
¥Expand HTML to support other frameworks such as Vue, Svelte, and Astro.
-
致力于 Markdown 支持,从解析器开始。
¥Work on Markdown support, starting from the parser.
-
继续完善类型推断基础架构,以便我们能够覆盖更多情况并添加新规则。
¥Continue working on the inference infrastructure, so we can cover more cases and add new rules.
-
以及更多!
¥and more!
我喜欢这个项目的发展方向,我能做些什么?
Section titled “我喜欢这个项目的发展方向,我能做些什么?”¥I like where this is going, how can I help?
我想提醒你,Biome 是一个由热爱编程、开源并秉持 Biome 理念的志愿者领导的项目,因此我们欢迎任何形式的帮助。 😁
¥I want to remind you that Biome is a project led by volunteers who like programming, open-source, and embrace the Biome philosophy, so any help is welcome 😁
¥Translations
如果你熟悉 Biome 并希望为其推广做出贡献,你可以将网站翻译成你的母语来帮助我们。在 dashboard 中,你可以检查支持的语言及其是否为最新版本。
¥If you are familiar with Biome and would like to contribute to its outreach, you can assist us by translating the website into your native language. In this dashboard, you can check the supported languages and if they are up to date.
¥Chat with us
加入我们的 Discord 服务器,与社区互动。与社区交流并成为社区的一份子也是一种贡献。
¥Join our Discord server, and engage with the community. Chatting with the community and being part of the community is a form of contribution.
¥Code contributions
如果你对项目的技术方面感兴趣,并且想要学习 Rust 语言,或者想要练习解析器、编译器、分析器等方面的知识,Biome 项目正是你所需要的!
¥If you like the technical aspects of the project, and you want to make your way into the Rust language, or practice your knowledge around parsers, compilers, analysers, etc., Biome is the project that does for you!
有很多方面值得探索;我保证你不会感到无聊。以下是一些你可以尝试的入门示例:
¥There are numerous aspects to explore; I assure you that you won’t get bored. Here is a small list of the things you can start with:
-
创建新的 lint 规则!我们还有很多规则尚未实现(例如 ESLint、ESLint 插件、Next.js、Solid 等)。我们有一个非常完善的 详尽的技术指南 文件。
¥Create new lint rules! We have so many rules that we haven’t implemented yet (ESLint, ESLint plugins, Next.js, Solid, etc.). We have a very extensive technical guide.
-
帮助 building Biome parsers!Biome 解析器的一个有趣之处在于,它们是可恢复的 容错能力 解析器,会生成 CST 而不是传统的抽象语法树 (AST)。
¥Help building Biome parsers! One interesting fact about Biome parsers is that they are recoverable parsers error resilient which emit a CST instead of a classic AST.
-
在我们的 LSP(语言服务器协议) 中实现新功能,或在我们的编辑器扩展中添加新功能:VS Code、Zed 和 JetBrains IntelliJ。
¥Implement new capabilities in our LSP (Language Server Protocol), or add new features in one of our editor extensions: VS Code, Zed and JetBrains IntelliJ.
¥Financial help
如果你相信本项目未来发展,可以通过 Open Collective 或 GitHub 赞助商 提供资金支持。
¥If you believe in the future of the project, you can also help with a financial contribution, via Open Collective or GitHub Sponsors.
此外,该项目提供了一个 企业支持计划,允许公司聘请一位核心贡献者来负责 Biome 工具链的特定方面。
¥Additionally, the project provides an enterprise support program where a company you can employ one of the core contributors to work a specific aspect of the Biome toolchain.
Biome v2.1 中文网 - 粤ICP备13048890号



