Skip to content

Biome v2.1

The brand of the project. It says "Biome, toolchain of the web" The brand of the project. It says "Biome, toolchain of the web"

Biome 2.0 发布至今不到一个月,用户数量就已大幅增长!我们的 Discord 群组非常活跃,下载量激增,bug 也层出不穷 :)

¥Biome 2.0 was released less than a month ago, and since then we have seen an amazing uptake! Our Discord is buzzing, our downloads are spiking, and bugs are rolling in :)

¥Faster scanner

主要争议点可能在于 Biome 2.0 引入了一个新的扫描器,我们用它来发现嵌套的配置文件,并在启用项目规则的情况下填充模块图。造成这种争议的原因是,使用扫描器会降低速度,而用户希望 Biome 能够快速运行。

¥Probably the main point of contention is that Biome 2.0 introduced a new scanner, which we use for discovering nested configuration files as well as for populating our module graph, if project rules are enabled. The reason for this contention is that having a scanner makes things slower, while people want Biome to be fast.

为了减轻影响,我们已将项目规则在 2.0 版本中设为可选,以便用户可以自行选择功能和速度。理想情况下,我们希望两者兼备。遗憾的是,即使没有项目规则,扫描器仍然会造成一些明显的开销。

¥To mitigate the impact, we already made the project rules opt-in for 2.0, so that users can choose between features and speed for themselves. But ideally, we’d have both. And unfortunately, even without project rules, the scanner still caused some noticeable overhead.

在 Biome 2.1 中,我们将更改 “轻量级扫描器”(项目规则已禁用)的工作逻辑。之前,它总是从项目根目录开始扫描整个项目;而现在,它会使用你要求 Biome 操作的文件和文件夹作为提示,来确定应该扫描项目的哪些部分。

¥For Biome 2.1 we’re changing the logic for how the “light scanner” (the one where project rules are disabled) works. Previously, it would always scan the entire project from its root, whereas now it will use the files and folders that you ask Biome to operate on as a hint for which parts of the project should be scanned.

这意味着如果你从项目根目录运行 Biome 而不带任何参数,则不会注意到任何差异。如果你指定要检查的特定文件,或者在嵌套文件夹中运行 Biome,扫描器将知道你感兴趣的项目部分,并仅扫描这些部分。

¥This means if you run Biome without any arguments from the project root, you are not going to notice a difference. But if you specify specific files to check, or if you run Biome inside a nested folder, the scanner will know which parts of the project you are interested in, and only scan those.

请注意,如果你启用了项目规则,则这些改进将不适用。这是因为项目规则通常需要从其他文件(包括你未指定的文件)中提取信息,因此目前我们仍然会扫描整个项目。

¥Note that if you have enabled project rules, these improvements don’t apply. This is because project rules often need to pull information from other files, including ones you didn’t specify, so we still scan the entire project for now.

¥Improved type inference

发布 Biome 2.0 时,我们提到过,我们的类型推断能够检测到 noFloatingPromises 规则 理想情况下应该检测到的约 75% 的情况。此后,我们已将此改进至约 85%,现在可以成功推断出以下情况:

¥When we released Biome 2.0, we mentioned that our type inference was able to detect ~75% of cases that our noFloatingPromises rule should ideally detect. Since then, we’ve been able to improve this to ~85%, and cases such as these can now be successfully inferred:

// We know that this evaluates to a `Promise`:
true && Promise.reject("logical operator bypass");
// But this doesn't:
false && Promise.reject("logical operator bypass");
// Similarly, we now detect that this may return a `Promise`:
const condition = Math.random() > -1; // Always true, but dynamic to linter
condition ? Promise.reject("ternary bypass") : null;
// On the other hand, we know the following is never a `Promise`:
const alwaysFalsy = 0;
alwaysFalsy ? Promise.reject("ternary bypass") : null;
// This will now get flagged because the `Promise`s are not handled:
[1, 2, 3].map(async (x) => x + 1);

此外,我们还添加了对 getter、调用签名、逗号运算符等的支持。我们的目标是让你无需担心 TypeScript 的哪些部分受支持,并且绝大多数情况下都支持 “即插即用”。此功能仍在开发中,但我们对目前的进展感到满意。

¥Additionally, we have added support for getters, call signatures, comma operators, and more. Our goal is for you to not have to worry about which parts of TypeScript are supported, and the vast majority of cases to “just work”. It’s still a work in progress, but we’re happy with the progress we are seeing.

最后,我们还添加了相关的规则 noMisusedPromises

¥And finally we have also added the related rule noMisusedPromises.

¥Rule updates

2.1.0 版本新增了以下规则:

¥The following new rules have been added in 2.1.0:

其他重要变更:

¥Other notable change:

¥Notable bug fixes

  • 如果你忽略了根配置中的嵌套配置文件,现在它将被正确忽略。

    ¥If you ignore a nested configuration file from your root configuration, it will now be properly ignored.

  • 从另一个配置扩展配置时,我们现在会正确忽略另一个配置中的 root。此版本在某些使用场景中导致了混淆。

    ¥When extending a configuration from another, we now correctly ignore the root of the other configuration. This one led to some confusion in several use cases.

¥What’s next

我们的 2.x 版本之旅仍处于早期阶段。扫描器和类型推断功能都可能得到进一步改进。此外,我们的 核心贡献者 将专注于推进 2025 年路线图 的开发,并重点关注以下功能:

¥It’s still early days in our 2.x journey. Both the scanner are type inference are likely to see further improvements. Additionally, our 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,以及(希望)Angular。

    ¥Expand HTML to support other frameworks such as Vue, Svelte, Astro and, hopefully, Angular too.

  • 致力于 Markdown 支持,从解析器开始。

    ¥Work on Markdown support, starting from the parser.

  • 以及更多!

    ¥and more!

¥Installation and migration

安装或更新 @biomejs/biome 包。如果你升级了软件包,请运行 migrate 命令。

¥Install or update the @biomejs/biome package. If you upgrade the package, run the migrate command.

Terminal window
npm install --save-dev --save-exact @biomejs/biome
npx @biomejs/biome migrate --write

migrate 命令会处理配置中的破坏性更改,因此你无需手动操作。

¥The migrate command takes care of breaking changes of the configuration, so you don’t have to.

我喜欢这个项目的发展方向,我能做些什么?

Section titled “我喜欢这个项目的发展方向,我能做些什么?”

¥I like where this is going, how can I help?

Biome 是一个由热爱编程、开源并认同 Biome 理念的志愿者领导的项目,因此我们欢迎任何形式的帮助。 😁

¥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:

¥Financial help

如果你相信本项目未来发展,可以通过 Open CollectiveGitHub 赞助商 提供资金支持。

¥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 as a company you can contract one of the core contributors to work on a specific aspect of the Biome toolchain.