Skip to content

noBiomeFirstException

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"suspicious": {
"noBiomeFirstException": "error"
}
}
}
}

¥Description

防止在 files.includes 字段中误用 glob 模式。

¥Prevents the misuse of glob patterns inside the files.includes field.

¥Leading of negated patterns

如果第一个 files.includes 模式以 ! 开头,则 Biome 将没有任何文件需要抓取。通常,最佳实践是先声明要包含的文件/文件夹,然后再声明要忽略的文件/文件夹。

¥If the first pattern of files.includes starts with the leading !, Biome won’t have any file to crawl. Generally, it is a good practice to declare the files/folders to include first, and then the files/folder to ignore.

查看 官方文档 以了解更多示例。

¥Check the official documentation for more examples.

¥Examples

¥Invalid

{
"files": {
"includes": ["!dist"]
}
}

¥Valid

{
"files": {
"includes": ["src/**", "!dist"]
}
}

¥Leading with catch-all **

如果用户配置文件继承自其他源(其他配置文件或库),并且这些源在 files.includes 中包含通配符 **,则当用户配置文件中也包含 ** 时,该规则将触发违规。

¥If the user configuration file extends from other sources (other configuration files or libraries), and those files contain the catch-all glob ** in files.includes, the rule will trigger a violation if also the user configuration file has a **.

¥Invalid

biome.json
{
"extends": ["./base.json"],
"files": {
"includes": ["**", "!**/test"]
}
}
base.json
{
"files": {
"includes": ["**", "!**/dist"]
}
}

¥Related links