配置
$schema
Section titled “$schema”允许将路径传递给 JSON 模式文件。
¥Allows to pass a path to a JSON schema file.
我们发布了 biome.json/biome.jsonc 文件的 JSON 模式文件。
¥We publish a JSON schema file for our biome.json/biome.jsonc files.
如果 @biomejs/biome NPM 包安装在 node_modules 文件夹中,你可以指定其内部 schema 的相对路径:
¥You can specify a relative path to the schema inside the @biomejs/biome NPM
package if it is installed in the node_modules folder:
{ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json"}如果你在解析物理文件时遇到问题,可以使用本站发布的文件:
¥If you have problems with resolving the physical file, you can use the one published on this site:
{ "$schema": "https://biome.nodejs.cn/schemas/2.0.5/schema.json"}extends
Section titled “extends”其他 Biome 配置文件路径列表。Biome 解析并应用 extends 列表中文件中的配置设置,并最终应用 biome.json/biome.jsonc 文件中的选项。
¥A list of paths to other Biome configuration files. Biome resolves and applies
the configuration settings from the files contained in the extends list, and
eventually applies the options contained in this biome.json/biome.jsonc
file.
要扩展的路径顺序从最不相关到最相关。
¥The order of paths to extend goes from least relevant to most relevant.
自 v2 版本起,此选项接受一个字符串,该字符串必须与值 "//" 匹配,可用于设置 monorepos。
¥Since v2, this option accepts a string that must match the value "//", which can be used
when setting up monorepos
此配置是否应被视为根配置。默认情况下,任何配置文件都被视为根目录。当配置文件是 “嵌套配置” 类型时,它必须设置 "root": false 类型,否则会抛出错误。
¥Whether this configuration should be treated as a root. By default, any configuration file is considered a root by default.
When a configuration file is a “nested configuration”, it must set "root": false, otherwise an error is thrown.
这是 Biome 同时在 CLI 和编辑器中协调多个文件所必需的。
¥This is required so Biome can orchestrate multiple files in CLI and editors at the same time.
默认:
true¥Default:
true
files.includes
Section titled “files.includes”待处理文件列表(glob 模式)。
¥A list of glob patterns of files to process.
如果文件夹匹配 glob 模式,则会处理该文件夹内的所有文件。
¥If a folder matches a glob pattern, all files inside that folder will be processed.
以下示例匹配 src 文件夹中所有扩展名为 .js 的文件:
¥The following example matches all files with a .js extension inside the src
folder:
{ "files": { "includes": ["src/**/*.js"] }}* 用于匹配文件夹中的所有文件,而 ** 会递归匹配文件夹中的所有文件和子文件夹。有关通配符的更多信息,请参阅 glob 语法参考 文档。
¥* is used to match all files in a folder, while ** recursively matches
all files and subfolders in a folder. For more information on globs, see the
glob syntax reference
includes 还支持否定模式或例外情况。这些模式以 ! 开头,可用于指示 Biome 处理除与否定模式匹配的文件之外的所有文件。使用否定模式时,应始终首先指定 ** 以匹配所有文件和文件夹,否则否定模式将无法匹配任何文件。
¥includes also supports negated patterns, or exceptions. These are patterns
that start with ! and they can be used to instruct Biome to process all files
except those matching the negated pattern. When using a negated pattern, you
should always specify ** first to match all files and folders, otherwise
the negated pattern will not match any files.
请注意,异常会按顺序处理,允许你为异常指定异常。
¥Note that exceptions are processed in order, allowing you to specify exceptions to exceptions.
请看以下示例:
¥Consider the following example:
{ "files": { "includes": ["**", "!**/*.test.js", "**/special.test.js", "!test"] }}此示例指定:
¥This example specifies that:
-
所有(子)文件夹内的所有文件都会被处理,这要归功于
**模式……¥All files inside all (sub)folders are processed, thanks to the
**pattern… -
…除非这些文件带有
.test.js扩展名……¥… except when those files have a
.test.jsextension… -
…但是文件
special.test.ts仍然会被处理……¥… but the file
special.test.tsis still processed… -
…但当它发生在名为
test的文件夹中时除外,因为该文件夹中的任何文件都不会被处理。¥… except when it occurs in the folder named
test, because no files inside that folder are processed.
这意味着:
¥This means that:
-
src/app.js已处理。¥
src/app.jsis processed. -
src/app.test.js未处理。¥
src/app.test.jsis not processed. -
src/special.test.js已处理。¥
src/special.test.jsis processed. -
test/special.test.js未处理。¥
test/special.test.jsis not processed.
请注意,无论 files.includes 设置如何,node_modules/ 中的文件都会被忽略。
¥Note that files inside node_modules/ are ignored regardless of the
files.includes setting.
与扫描器交互
Section titled “与扫描器交互”¥Interaction with the scanner
Biome 包含一个 scanner 组件,负责发现嵌套的配置文件以及 .gitignore 文件。如果启用了 项目域名 中的一条或多条规则,它还可以索引源文件。
¥Biome has a scanner that is responsible for
discovering nested configuration files as well as .gitignore files. It can
also index source files if one or more rules from the
project domain are enabled.
扫描器会同时考虑 files.includes 和 .gitignore 文件中被忽略的模式,但有两个例外需要注意:
¥The scanner respects both files.includes and the ignored patterns from
.gitignore files, but there are two exceptions to be aware of:
-
biome.json和.gitignore等特殊文件优先于files.includes中任何被忽略的模式。¥Special files such as
biome.jsonand.gitignoretake priority over any ignored patterns infiles.includes. -
如果启用了项目域中的任何规则,扫描器将索引源文件及其依赖。这意味着,只要有另一个包含的文件导入了这些文件,即使作为
files.includes的一部分被忽略的文件仍然可能被扫描器索引。这也意味着node_modules/中的.d.ts文件和package.json清单仍然可能会被索引。¥If any rule from the project domain is enabled, the scanner will index source files including their dependencies. This means that files that are ignored as part of
files.includesmay still get indexed by the scanner, as long as there is another included file that imports those files. And this also means that.d.tsfiles andpackage.jsonmanifests insidenode_modules/may still get indexed too.
如果你想显式地强制扫描器忽略某些文件,可以使用所谓的强制忽略模式。强制忽略模式看起来像一个普通的否定模式,但以双感叹号 (!!) 开头。
¥If you want to explicitly force some files to be ignored by the scanner, you can
do so using a so-called force-ignore pattern. A force-ignore pattern looks
like a regular negated pattern, but starts with a double exclamation mark
(!!).
例如,你可以使用以下配置告诉 Biome 永远不要查看任何 dist/ 文件夹:
¥For example, you can tell Biome to never look inside any dist/ folder using
the following configuration:
{ "files": { "includes": ["**", "!!**/dist"] }}我们建议对包含输出文件(例如 build/ 和 dist/)的任何文件夹使用强制忽略语法。对于此类文件夹,建立索引几乎不可能带来任何实际好处。对于包含生成文件的文件夹,我们建议使用常规的忽略模式,以便仍然可以从文件中提取类型信息。
¥We recommend using the force-ignore syntax for any folders that contain output
files, such as build/ and dist/. For such folders, it is highly unlikely
that indexing has any useful benefits. For folders containing generated files,
we advise using regular ignore patterns so that type information can still be
extracted from the files.
对于嵌套的 biome.json 文件以及你希望显式忽略的 .gitignore 文件,还必须使用强制忽略语法。
¥For nested biome.json files as well as .gitignore files that you wish to
explicitly ignore, the force-ignore syntax must also be used.
files.ignoreUnknown
Section titled “files.ignoreUnknown”如果设置了 true,则当 Biome 遇到无法处理的文件时,不会发出诊断信息。
¥If true, Biome won’t emit diagnostics if it encounters files that it can’t
handle.
{ "files": { "ignoreUnknown": true }}默认:
false¥Default:
false
files.maxSize
Section titled “files.maxSize”源代码文件的最大允许大小(以字节为单位)。出于性能原因,超过此限制的文件将被忽略。
¥The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reasons.
默认:
1048576(1024*1024, 1MB)¥Default:
1048576(1024*1024, 1MB)
files.experimentalScannerIgnores
Section titled “files.experimentalScannerIgnores”扫描器在爬取过程中应忽略的字面路径段数组。被忽略的文件不会被索引,这意味着这些文件不会出现在模块图中,也不会从中推断类型。
¥An array of literal path segments that the scanner should ignore during the crawling. The ignored files won’t be indexed, which means that these files won’t be part of the module graph, and types won’t be inferred from them.
用于将 Biome 与版本控制软件 (VCS) 集成的属性集。
¥Set of properties to integrate Biome with a VCS (Version Control Software).
vcs.enabled
Section titled “vcs.enabled”Biome 是否应该将自身与 VCS 客户端集成
¥Whether Biome should integrate itself with the VCS client
默认:
false¥Default:
false
vcs.clientKind
Section titled “vcs.clientKind”客户端类型。
¥The kind of client.
值:
¥Values:
"git"
vcs.useIgnoreFile
Section titled “vcs.useIgnoreFile”Biome 是否应使用项目的版本控制系统忽略文件。使用 true 时,Biome 将忽略版本控制系统忽略文件中指定的文件以及 .ignore 文件中指定的文件。
¥Whether Biome should use the project’s VCS ignore files. When true, Biome will ignore the files
specified in the VCS ignore files as well as those specified in .ignore files.
此功能还支持嵌套的忽略文件。
¥This feature supports nested ignore files too.
根忽略文件与根 files.includes 具有相同的语义。
¥The root ignore file yields the same semantics as the root files.includes.
vcs.root
Section titled “vcs.root”Biome 应检查 VCS 文件的文件夹。默认情况下,Biome 将使用找到 biome.json 的同一文件夹。
¥The folder where Biome should check for VCS files. By default, Biome will use the same
folder where biome.json was found.
如果 Biome 找不到配置,它将尝试使用当前工作目录。如果找不到当前工作目录,Biome 将不会使用 VCS 集成,并且将发出诊断
¥If Biome can’t find the configuration, it will attempt to use the current working directory. If no current working directory can’t be found, Biome won’t use the VCS integration, and a diagnostic will be emitted
vcs.defaultBranch
Section titled “vcs.defaultBranch”项目的主分支。Biome 将在评估更改的文件时使用此分支。
¥The main branch of the project. Biome will use this branch when evaluating the changed files.
linter
Section titled “linter”linter.enabled
Section titled “linter.enabled”启用 Biome 的代码检查器。
¥Enables Biome’s linter.
默认:
true¥Default:
true
linter.includes
Section titled “linter.includes”待检查文件列表(glob 模式)。
¥A list of glob patterns of files to lint.
以下示例检查 src 文件夹中所有扩展名为 .js 的文件:
¥The following example lints all files with a .js extension inside the src
folder:
{ "linter": { "includes": ["src/**/*.js"] }}* 用于匹配文件夹中的所有文件,而 ** 会递归匹配文件夹中的所有文件和子文件夹。有关通配符的更多信息,请参阅 glob 语法参考 文档。
¥* is used to match all files in a folder, while ** recursively matches
all files and subfolders in a folder. For more information on globs, see the
glob syntax reference
includes 还支持否定模式或例外情况。这些模式以 ! 开头,可用于指示 Biome 处理除与否定模式匹配的文件之外的所有文件。
¥includes also supports negated patterns, or exceptions. These are patterns
that start with ! and they can be used to instruct Biome to process all files
except those matching the negated pattern.
请注意,异常会按顺序处理,允许你为异常指定异常。
¥Note that exceptions are processed in order, allowing you to specify exceptions to exceptions.
请看以下示例:
¥Consider the following example:
{ "linter": { "includes": ["**", "!**/*.test.js", "**/special.test.js"] }}此示例指定:
¥This example specifies that:
-
所有(子)文件夹内的所有文件都会被检查代码,这要归功于
**模式……¥All files inside all (sub)folders are linted, thanks to the
**pattern… -
…除非这些文件带有
.test.js扩展名……¥… except when those files have a
.test.jsextension… -
…但是文件
special.test.ts仍然会被检查代码。¥… but the file
special.test.tsis still linted.
这意味着:
¥This means that:
-
src/app.js已进行代码检查。¥
src/app.jsis linted. -
src/app.test.js未进行代码检查。¥
src/app.test.jsis not linted. -
src/special.test.js*已进行代码检查。¥
src/special.test.js*is linted.
请注意,linter.includes 应用于 files.includes 之后。这意味着任何未与 files.includes 匹配的文件将无法再与 linter.includes 匹配。这意味着以下示例将无法正常工作:
¥Note that linter.includes is applied after files.includes. This means
that any file that is not matched by files.includes can no longer be matched
linter.includes. This means the following example doesn’t work:
{ "files": { "includes": "src/**" }, "linter": { // This matches nothing because there is no overlap with `files.includes`: "includes": "scripts/**" }}如果未指定 linter.includes,则所有与 files.includes 匹配的文件都会被检查代码结构。
¥If linter.includes is not specified, all files matched by
files.includes are linted.
linter.rules.recommended
Section titled “linter.rules.recommended”启用所有组的推荐规则。
¥Enables the recommended rules for all groups.
默认:
true¥Default:
true
linter.rules.[group]
Section titled “linter.rules.[group]”影响单个组规则的选项。Biome 支持以下组:
¥Options that influence the rules of a single group. Biome supports the following groups:
-
辅助功能:规则侧重于防止可访问性问题。
¥accessibility: Rules focused on preventing accessibility problems.
-
复杂度:侧重于检查可以简化的复杂代码的规则。
¥complexity: Rules that focus on inspecting complex code that could be simplified.
-
正确性:检测肯定不正确或无用的代码的规则。
¥correctness: Rules that detect code that is guaranteed to be incorrect or useless.
-
nursery:仍在开发中的新规则。初始规则需要在稳定版本中通过配置显式选择启用,因为它们可能仍然存在错误或性能问题(即使它们被标记为推荐)。它们在每日构建版本中默认启用,但由于它们不稳定,其诊断严重性可能会设置为错误或警告,具体取决于我们是否打算在规则最终稳定后推荐该规则。初始规则一旦稳定,就会被提升到其他组,或者可能被移除。属于此组的规则不受语义版本控制。
¥nursery: New rules that are still under development. Nursery rules require explicit opt-in via configuration on stable versions because they may still have bugs or performance problems (even if they are marked as recommended). They are enabled by default on nightly builds, but as they are unstable their diagnostic severity may be set to either error or warning, depending on whether we intend for the rule to be recommended or not when it eventually gets stabilized. Nursery rules get promoted to other groups once they become stable or may be removed. Rules that belong to this group are not subject to semantic version.
-
性能:规则捕捉可以编写代码以使其运行得更快或通常更高效的方法。
¥performance: Rules catching ways your code could be written to run faster, or generally be more efficient.
-
安全性:检测潜在安全漏洞的规则。
¥security: Rules that detect potential security flaws.
-
样式:规则强制以一致且惯用的方式编写代码。
¥style: Rules enforcing a consistent and idiomatic way of writing your code.
-
可疑:检测可能不正确或无用的代码的规则。
¥suspicious: Rules that detect code that is likely to be incorrect or useless.
每个组可以接受一个字符串作为值,该字符串表示严重性;或者接受一个对象作为值,用于配置每条规则。
¥Each group can accept, as a value, a string that represents the severity or an object where each rule can be configured.
传递严重性参数时,你可以控制属于同一组的所有规则发出的严重性级别。例如,你可以配置 a11y 组以发出诊断信息:
¥When passing the severity, you can control the severity emitted by all the rules that belong to a group.
For example, you can configure the a11y group to emit information diagnostics:
{ "linter": { "rules": { "a11y": "info" } }}以下是可接受的值:
¥Here are the accepted values:
-
"on":该组中的每条规则都会发出一条具有默认严重性的诊断信息。请参阅规则文档,或使用explain命令:¥
"on": each rule that belongs to the group will emit a diagnostic with the default severity of the rule. Refer to the documentation of the rule, or use theexplaincommand:Terminal window biome explain noDebugger -
"off":属于该组的任何规则都不会发出任何诊断信息。¥
"off": none of the rules that belong to the group will emit any diagnostics. -
"info":属于该组的所有规则都将发出 诊断信息级别。¥
"info": all rules that belong to the group will emit a diagnostic with information severity. -
"warn":属于该组的所有规则都将发出 诊断警告级别。¥
"warn": all rules that belong to the group will emit a diagnostic with warning severity. -
"error":属于该组的所有规则都将发出 错误严重性诊断。¥
"error": all rules that belong to the group will emit a diagnostic with error severity.
linter.rules.[group].recommended
Section titled “linter.rules.[group].recommended”为单个组启用推荐规则。
¥Enables the recommended rules for a single group.
示例:
¥Example:
{ "linter": { "enabled": true, "rules": { "nursery": { "recommended": true } } }}assist
Section titled “assist”assist.enabled
Section titled “assist.enabled”启用 Biome 的辅助功能。
¥Enables Biome’s assist.
默认:
true¥Default:
true
assist.includes
Section titled “assist.includes”待检查文件列表(glob 模式)。
¥A list of glob patterns of files to lint.
以下示例分析 src 文件夹中所有扩展名为 .js 的文件:
¥The following example analyzes all files with a .js extension inside the src
folder:
{ "assist": { "includes": ["src/**/*.js"] }}* 用于匹配文件夹中的所有文件,而 ** 会递归匹配文件夹中的所有文件和子文件夹。有关通配符的更多信息,请参阅 glob 语法参考 文档。
¥* is used to match all files in a folder, while ** recursively matches
all files and subfolders in a folder. For more information on globs, see the
glob syntax reference
includes 还支持否定模式或例外情况。这些模式以 ! 开头,可用于指示 Biome 处理除与否定模式匹配的文件之外的所有文件。
¥includes also supports negated patterns, or exceptions. These are patterns
that start with ! and they can be used to instruct Biome to process all files
except those matching the negated pattern.
请注意,异常会按顺序处理,允许你为异常指定异常。
¥Note that exceptions are processed in order, allowing you to specify exceptions to exceptions.
请看以下示例:
¥Consider the following example:
{ "assist": { "includes": ["**", "!**/*.test.js", "**/special.test.js"] }}此示例指定:
¥This example specifies that:
-
所有(子)文件夹内的所有文件都会被分析,这要归功于
**模式……¥All files inside all (sub)folders are analyzed, thanks to the
**pattern… -
…除非这些文件带有
.test.js扩展名……¥… except when those files have a
.test.jsextension… -
…但是文件
special.test.ts仍然会被分析。¥… but the file
special.test.tsis still analyzed.
这意味着:
¥This means that:
-
src/app.js已分析。¥
src/app.jsis analysed. -
src/app.test.js未分析。¥
src/app.test.jsis not analyzed. -
src/special.test.js*已分析。¥
src/special.test.js*is analyzed.
请注意,assist.includes 应用于 files.includes 之后。这意味着任何未与 files.includes 匹配的文件将无法再与 assist.includes 匹配。这意味着以下示例将无法正常工作:
¥Note that assist.includes is applied after files.includes. This means
that any file that is not matched by files.includes can no longer be matched
assist.includes. This means the following example doesn’t work:
{ "files": { "includes": "src/**" }, "assist": { // This matches nothing because there is no overlap with `files.includes`: "includes": "scripts/**" }}如果未指定 assist.includes,则所有与 files.includes 匹配的文件都会被检查代码结构。
¥If assist.includes is not specified, all files matched by
files.includes are linted.
assist.actions.recommended
Section titled “assist.actions.recommended”启用所有组的推荐操作。
¥Enables the recommended actions for all groups.
assist.actions.[group]
Section titled “assist.actions.[group]”影响单个组规则的选项。Biome 支持以下组:
¥Options that influence the rules of a single group. Biome supports the following groups:
-
源代码:此组表示在保存文档时可以安全应用的操作。这些操作通常都是安全的,它们通常不会改变程序的功能。
¥source: This group represents those actions that can be safely applied to a document upon saving. These actions are all generally safe, they typically don’t change the functionality of the program.
assist.actions.[group].recommended
Section titled “assist.actions.[group].recommended”为单个组启用推荐规则。
¥Enables the recommended rules for a single group.
示例:
¥Example:
{ "assist": { "enabled": true, "actions": { "source": { "recommended": true } } }}formatter
Section titled “formatter”这些选项适用于所有语言。下面还有其他特定于语言的格式选项。
¥These options apply to all languages. There are additional language-specific formatting options below.
formatter.enabled
Section titled “formatter.enabled”启用 Biome 的格式化器。
¥Enables Biome’s formatter.
默认:
true¥Default:
true
formatter.includes
Section titled “formatter.includes”待格式化文件列表(glob 模式)。
¥A list of glob patterns of files to format.
以下示例格式化 src 文件夹中所有扩展名为 .js 的文件:
¥The following example formats all files with a .js extension inside the src
folder:
{ "formatter": { "includes": ["src/**/*.js"] }}* 用于匹配文件夹中的所有文件,而 ** 会递归匹配文件夹中的所有文件和子文件夹。有关通配符的更多信息,请参阅 glob 语法参考 文档。
¥* is used to match all files in a folder, while ** recursively matches
all files and subfolders in a folder. For more information on globs, see the
glob syntax reference
includes 还支持否定模式或例外情况。这些模式以 ! 开头,可用于指示 Biome 处理除与否定模式匹配的文件之外的所有文件。
¥includes also supports negated patterns, or exceptions. These are patterns
that start with ! and they can be used to instruct Biome to process all files
except those matching the negated pattern.
请注意,异常会按顺序处理,允许你为异常指定异常。
¥Note that exceptions are processed in order, allowing you to specify exceptions to exceptions.
请看以下示例:
¥Consider the following example:
{ "formatter": { "includes": ["**", "!**/*.test.js", "**/special.test.js"] }}此示例指定:
¥This example specifies that:
-
所有(子)文件夹内的所有文件都会被格式化,这要归功于
**模式……¥All files inside all (sub)folders are formatted, thanks to the
**pattern… -
…除非这些文件带有
.test.js扩展名……¥… except when those files have a
.test.jsextension… -
…但是文件
special.test.ts仍然会被格式化。¥… but the file
special.test.tsis still formatted.
这意味着:
¥This means that:
-
src/app.js已格式化。¥
src/app.jsis formatted. -
src/app.test.js未格式化。¥
src/app.test.jsis not formatted. -
src/special.test.js已格式化。¥
src/special.test.jsis formatted.
请注意,formatter.includes 应用于 files.includes 之后。这意味着任何未与 files.includes 匹配的文件将无法再与 formatter.includes 匹配。这意味着以下示例将无法正常工作:
¥Note that formatter.includes is applied after files.includes. This means
that any file that is not matched by files.includes can no longer be matched
formatter.includes. This means the following example doesn’t work:
{ "files": { "includes": "src/**" }, "formatter": { // This matches nothing because there is no overlap with `files.includes`: "includes": "scripts/**" }}如果未指定 formatter.includes,则所有与 files.includes 匹配的文件都会被格式化。
¥If formatter.includes is not specified, all files matched by
files.includes are formatted.
formatter.formatWithErrors
Section titled “formatter.formatWithErrors”允许格式化有语法错误的文档。
¥Allows to format a document that has syntax errors.
{ "formatter": { "formatWithErrors": true }}默认:
false¥Default:
false
formatter.indentStyle
Section titled “formatter.indentStyle”缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
formatter.indentWidth
Section titled “formatter.indentWidth”缩进应该有多大。
¥How big the indentation should be.
默认:
2¥Default:
2
formatter.lineEnding
Section titled “formatter.lineEnding”行尾类型。
¥The type of line ending.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
formatter.lineWidth
Section titled “formatter.lineWidth”单行可写入的字符数。
¥The amount of characters that can be written on a single line..
默认:
80¥Default:
80
formatter.attributePosition
Section titled “formatter.attributePosition”HTMLish 语言中的属性位置样式。
¥The attribute position style in HTMLish languages.
-
"auto",属性会自动格式化,只有当它们符合某些条件时,它们才会折叠在多行中;¥
"auto", the attributes are automatically formatted, and they will collapse in multiple lines only when they hit certain criteria; -
"multiline",如果属性超过一个,则属性将折叠成多行。已使用。¥
"multiline", the attributes will collapse in multiple lines if more than 1 attribute is used.
默认:
"auto"¥Default:
"auto"
formatter.bracketSpacing
Section titled “formatter.bracketSpacing”选择是否在括号和内部值之间添加空格。
¥Choose whether spaces should be added between brackets and inner values.
默认:
true¥Default:
true
formatter.expand
Section titled “formatter.expand”是否将数组和对象展开到多行。
¥Whether to expand arrays and objects on multiple lines.
-
"auto",如果第一个属性包含换行符,则对象字面量将格式化为多行;如果数组字面量适合一行,则将其格式化为单行。¥
"auto", object literals are formatted on multiple lines if the first property has a newline, and array literals are formatted on a single line if it fits in the line. -
"always",无论列表长度如何,这些字面量都将格式化为多行。¥
"always", these literals are formatted on multiple lines, regardless of length of the list. -
"never",如果一行足够,这些字面量将格式化为一行。¥
"never", these literals are formatted on a single line if it fits in the line.
格式化 package.json 时,除非另有配置,否则 Biome 将使用 always。
¥When formatting package.json, Biome will use always unless configured otherwise.
默认:
"auto"¥Default:
"auto"
formatter.useEditorconfig
Section titled “formatter.useEditorconfig”Biome 是否应使用 .editorconfig 文件来确定格式化选项。
¥Whether Biome should use the .editorconfig file to determine the formatting options.
配置文件 .editorconfig 和 biome.json 将遵循以下规则:
¥The config files .editorconfig and biome.json will follow the following rules:
-
biome.json文件中的格式化设置始终优先于.editorconfig文件。¥Formatting settings in
biome.jsonalways take precedence over.editorconfigfiles. -
层级高于
biome.json文件的.editorconfig文件已被忽略。这是为了避免将用户主目录中的格式设置加载到包含biome.json文件的项目中。¥
.editorconfigfiles that exist higher up in the hierarchy than abiome.jsonfile are already ignored. This is to avoid loading formatting settings from someone’s home directory into a project with abiome.jsonfile. -
目前不支持嵌套的
.editorconfig文件。¥Nested
.editorconfigfiles aren’t supported currently.
默认:
false¥Default:
false
javascript
Section titled “javascript”这些选项仅适用于 JavaScript(和 TypeScript)文件。
¥These options apply only to JavaScript (and TypeScript) files.
javascript.parser.unsafeParameterDecoratorsEnabled
Section titled “javascript.parser.unsafeParameterDecoratorsEnabled”允许支持不安全/实验性参数装饰器。
¥Allows to support the unsafe/experimental parameter decorators.
{ "javascript": { "parser": { "unsafeParameterDecoratorsEnabled": true } }}默认:
false¥Default:
false
javascript.parser.jsxEverywhere
Section titled “javascript.parser.jsxEverywhere”设置为 true 时,允许解析 .js 文件中的 JSX 语法。设置为 false 时,Biome 会在遇到 .js 文件中的 JSX 语法时发出诊断信息。
¥When set to true, allows to parse JSX syntax inside .js files. When set to false, Biome will raise diagnostics when it encounters JSX syntax inside .js files.
默认:
true¥Default:
true
{ "javascript": { "parser": { "jsxEverywhere": false } }}javascript.formatter.quoteStyle
Section titled “javascript.formatter.quoteStyle”表示字符串文字时使用的引号类型。它可以是 "single" 或 "double"。
¥The type of quote used when representing string literals. It can be "single" or "double".
默认:
"double"¥Default:
"double"
{ "javascript": { "formatter": { "quoteStyle": "single" } }}javascript.formatter.jsxQuoteStyle
Section titled “javascript.formatter.jsxQuoteStyle”表示 jsx 字符串文字时使用的引号类型。它可以是 "single" 或 "double"。
¥The type of quote used when representing jsx string literals. It can be "single" or "double".
默认:
"double"¥Default:
"double"
{ "javascript": { "formatter": { "jsxQuoteStyle": "single" } }}javascript.formatter.quoteProperties
Section titled “javascript.formatter.quoteProperties”对象内的属性应何时用引号引起来。它可以是 "asNeeded" 或 "preserve"。
¥When properties inside objects should be quoted. It can be "asNeeded" or "preserve".
默认:
"asNeeded"¥Default:
"asNeeded"
{ "javascript": { "formatter": { "quoteProperties": "preserve" } }}javascript.formatter.trailingCommas
Section titled “javascript.formatter.trailingCommas”在多行逗号分隔的语法结构中尽可能打印尾随逗号。可能的值:
¥Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Possible values:
-
"all",始终添加尾随逗号;¥
"all", the trailing comma is always added; -
"es5",仅在旧版本 JavaScript 支持的地方添加尾随逗号;¥
"es5", the trailing comma is added only in places where it’s supported by older version of JavaScript; -
"none",从不添加尾随逗号。¥
"none", trailing commas are never added.
默认:
"all"¥Default:
"all"
javascript.formatter.semicolons
Section titled “javascript.formatter.semicolons”它配置格式化程序打印分号的位置:
¥It configures where the formatter prints semicolons:
-
"always",分号始终添加在每个语句的末尾;¥
"always", the semicolons is always added at the end of each statement; -
"asNeeded",仅在需要的地方添加分号,以防止 ASI。¥
"asNeeded", the semicolons are added only in places where it’s needed, to protect from ASI.
默认:
"always"¥Default:
"always"
示例:
¥Example:
{ "javascript": { "formatter": { "semicolons": "asNeeded" } }}javascript.formatter.arrowParentheses
Section titled “javascript.formatter.arrowParentheses”是否向箭头函数添加不必要的括号:
¥Whether to add non-necessary parentheses to arrow functions:
-
"always",始终添加括号;¥
"always", the parentheses are always added; -
"asNeeded",只有在需要时才添加括号。¥
"asNeeded", the parentheses are added only when they are needed.
默认:
"always"¥Default:
"always"
javascript.formatter.enabled
Section titled “javascript.formatter.enabled”为 JavaScript(及其超级语言)文件启用 Biome 的格式化程序。
¥Enables Biome’s formatter for JavaScript (and its super languages) files.
默认:
true¥Default:
true
javascript.formatter.indentStyle
Section titled “javascript.formatter.indentStyle”JavaScript(及其超级语言)文件的缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation for JavaScript (and its super languages) files. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
javascript.formatter.indentWidth
Section titled “javascript.formatter.indentWidth”JavaScript(及其超级语言)文件的缩进应该有多大。
¥How big the indentation should be for JavaScript (and its super languages) files.
默认:
2¥Default:
2
javascript.formatter.lineEnding
Section titled “javascript.formatter.lineEnding”JavaScript(及其超级语言)文件的行尾类型。
¥The type of line ending for JavaScript (and its super languages) files.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
javascript.formatter.lineWidth
Section titled “javascript.formatter.lineWidth”JavaScript(及其上级语言)文件中单行可写入的字符数。
¥The amount of characters that can be written on a single line in JavaScript (and its super languages) files.
默认:
80¥Default:
80
javascript.formatter.bracketSameLine
Section titled “javascript.formatter.bracketSameLine”选择是否应在括号和内部值之间添加空格
¥Choose whether the ending > of a multi-line JSX element should be on the last attribute line or not
默认:
false¥Default:
false
javascript.formatter.bracketSpacing
Section titled “javascript.formatter.bracketSpacing”选择是否在括号和内部值之间添加空格。
¥Choose whether spaces should be added between brackets and inner values.
默认:
true¥Default:
true
javascript.formatter.attributePosition
Section titled “javascript.formatter.attributePosition”jsx 元素中的属性位置样式。
¥The attribute position style in jsx elements.
-
"auto",不强制每行一个属性。¥
"auto", do not enforce single attribute per line. -
"multiline",强制每行一个属性。¥
"multiline", enforce single attribute per line.
默认:
"auto"¥Default:
"auto"
javascript.formatter.expand
Section titled “javascript.formatter.expand”是否将数组和对象展开到多行。
¥Whether to expand arrays and objects on multiple lines.
-
"auto",如果第一个属性包含换行符,则对象字面量将格式化为多行;如果数组字面量适合一行,则将其格式化为单行。¥
"auto", object literals are formatted on multiple lines if the first property has a newline, and array literals are formatted on a single line if it fits in the line. -
"always",无论列表长度如何,这些字面量都将格式化为多行。¥
"always", these literals are formatted on multiple lines, regardless of length of the list. -
"never",如果一行足够,这些字面量将格式化为一行。¥
"never", these literals are formatted on a single line if it fits in the line.
默认:
"auto"¥Default:
"auto"
javascript.formatter.operatorLinebreak
Section titled “javascript.formatter.operatorLinebreak”将二进制表达式拆分为多行时,应确定是在二元运算符之前还是之后进行拆分。
¥When breaking binary expressions into multiple lines, whether to break them before or after the binary operator.
默认:
"after"。¥Default:
"after".
-
"after:运算符位于表达式之后:¥
"after: the operator is placed after the expression:file.js if (expressionOne &&expressionTwo &&expressionThree &&expressionFour) {} -
"before:运算符位于表达式之前:¥
"before: the operator is placed before the expression:file.js if (expressionOne&& expressionTwo&& expressionThree&& expressionFour) {}
javascript.globals
Section titled “javascript.globals”Biome 应忽略的全局名称列表(分析器、linter 等)
¥A list of global names that Biome should ignore (analyzer, linter, etc.)
{ "javascript": { "globals": ["$", "_", "externalVariable"] }}javascript.jsxRuntime
Section titled “javascript.jsxRuntime”表示用于解释 JSX 的运行时或转换的类型。
¥Indicates the type of runtime or transformation used for interpreting JSX.
-
"transparent"— 表示现代或原生 JSX 环境,不需要 Biome 进行特殊处理。¥
"transparent"— Indicates a modern or native JSX environment, that doesn’t require special handling by Biome. -
"reactClassic"— 表示需要React导入的经典 React 环境。对应于 TypeScript 的tsconfig.json中jsx选项的react值。¥
"reactClassic"— Indicates a classic React environment that requires theReactimport. Corresponds to thereactvalue for thejsxoption in TypeScript’stsconfig.json.
{ "javascript": { "jsxRuntime": "reactClassic" }}有关旧 JSX 运行时与新 JSX 运行时的更多信息,请参阅:https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
¥For more information about the old vs. new JSX runtime, please see: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
默认:
"transparent"¥Default:
"transparent"
javascript.linter.enabled
Section titled “javascript.linter.enabled”启用 Biome 的 JavaScript(及其上级语言)文件代码检查器。
¥Enables Biome’s linter for JavaScript (and its super languages) files.
默认:
true¥Default:
true
{ "javascript": { "linter": { "enabled": false } }}javascript.assist.enabled
Section titled “javascript.assist.enabled”启用 Biome 对 JavaScript(及其上级语言)文件的支持。
¥Enables Biome’s assist for JavaScript (and its super languages) files.
默认:
true¥Default:
true
{ "javascript": { "assist": { "enabled": false } }}应用于 JSON 文件的选项。
¥Options applied to the JSON files.
json.parser.allowComments
Section titled “json.parser.allowComments”启用 JSON 文件中注释的解析。
¥Enables the parsing of comments in JSON files.
{ "json": { "parser": { "allowComments": true } }}json.parser.allowTrailingCommas
Section titled “json.parser.allowTrailingCommas”启用解析 JSON 文件中的尾随逗号。
¥Enables the parsing of trailing commas in JSON files.
{ "json": { "parser": { "allowTrailingCommas": true } }}json.formatter.enabled
Section titled “json.formatter.enabled”为 JSON(及其超级语言)文件启用 Biome 的格式化程序。
¥Enables Biome’s formatter for JSON (and its super languages) files.
默认:
true¥Default:
true
{ "json": { "formatter": { "enabled": false } }}json.formatter.indentStyle
Section titled “json.formatter.indentStyle”JSON(及其超级语言)文件的缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation for JSON (and its super languages) files. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
json.formatter.indentWidth
Section titled “json.formatter.indentWidth”JSON(及其超级语言)文件的缩进应该有多大。
¥How big the indentation should be for JSON (and its super languages) files.
默认:
2¥Default:
2
json.formatter.lineEnding
Section titled “json.formatter.lineEnding”JSON(及其超级语言)文件的行尾类型。
¥The type of line ending for JSON (and its super languages) files.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
json.formatter.lineWidth
Section titled “json.formatter.lineWidth”JSON(及其上级语言)文件中单行可写入的字符数。
¥The amount of characters that can be written on a single line in JSON (and its super languages) files.
默认:
80¥Default:
80
json.formatter.trailingCommas
Section titled “json.formatter.trailingCommas”在多行逗号分隔的语法结构中尽可能打印尾随逗号。
¥Print trailing commas wherever possible in multi-line comma-separated syntactic structures.
允许的值:
¥Allowed values:
-
"none":尾随逗号被删除;¥
"none": the trailing comma is removed; -
"all":保留尾随逗号并优先使用。¥
"all": the trailing comma is kept and preferred.
默认:
"none"¥Default:
"none"
json.formatter.bracketSpacing
Section titled “json.formatter.bracketSpacing”选择是否在括号和内部值之间添加空格。
¥Choose whether spaces should be added between brackets and inner values.
默认:
true¥Default:
true
json.formatter.expand
Section titled “json.formatter.expand”是否将数组和对象展开到多行。
¥Whether to expand arrays and objects on multiple lines.
-
"auto",如果第一个属性包含换行符,则对象字面量将格式化为多行;如果数组字面量适合一行,则将其格式化为单行。¥
"auto", object literals are formatted on multiple lines if the first property has a newline, and array literals are formatted on a single line if it fits in the line. -
"always",无论列表长度如何,这些字面量都将格式化为多行。¥
"always", these literals are formatted on multiple lines, regardless of length of the list. -
"never",如果一行足够,这些字面量将格式化为一行。¥
"never", these literals are formatted on a single line if it fits in the line.
格式化 package.json 时,除非另有配置,否则 Biome 将使用 always。
¥When formatting package.json, Biome will use always unless configured otherwise.
默认:
"auto"¥Default:
"auto"
json.linter.enabled
Section titled “json.linter.enabled”为 JSON(及其超级语言)文件启用 Biome 的格式化程序。
¥Enables Biome’s formatter for JSON (and its super languages) files.
默认:
true¥Default:
true
{ "json": { "linter": { "enabled": false } }}json.assist.enabled
Section titled “json.assist.enabled”启用 Biome 对 JSON(及其上级语言)文件的支持。
¥Enables Biome’s assist for JSON (and its super languages) files.
默认:
true¥Default:
true
{ "json": { "assist": { "enabled": false } }}应用于 CSS 文件的选项。
¥Options applied to the CSS files.
css.parser.cssModules
Section titled “css.parser.cssModules”启用 CSS 模块 的解析
¥Enables parsing of CSS modules
默认:
false¥Default:
false
css.parser.tailwindDirectives
Section titled “css.parser.tailwindDirectives”启用对 Tailwind 特定语法(例如 @theme、@utility 和 @apply)的解析。
¥Enables parsing of Tailwind specific syntax, like @theme, @utility and @apply.
默认:
false¥Default:
false
css.formatter.enabled
Section titled “css.formatter.enabled”启用 Biome 的 CSS 文件格式化程序。
¥Enables Biome’s formatter for CSS files.
默认:
false¥Default:
false
{ "css": { "formatter": { "enabled": false } }}css.formatter.indentStyle
Section titled “css.formatter.indentStyle”CSS 文件的缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation for CSS files. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
css.formatter.indentWidth
Section titled “css.formatter.indentWidth”CSS 文件的缩进大小。
¥How big the indentation should be for CSS files.
默认:
2¥Default:
2
{ "css": { "formatter": { "indentWidth": 2 } }}css.formatter.lineEnding
Section titled “css.formatter.lineEnding”CSS 文件的行尾类型。
¥The type of line ending for CSS files.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
css.formatter.lineWidth
Section titled “css.formatter.lineWidth”CSS 文件中单行可写入的字符数。
¥The amount of characters that can be written on a single line in CSS files.
默认:
80¥Default:
80
css.formatter.quoteStyle
Section titled “css.formatter.quoteStyle”表示字符串文字时使用的引号类型。它可以是 "single" 或 "double"。
¥The type of quote used when representing string literals. It can be "single" or "double".
默认:
"double"¥Default:
"double"
css.linter.enabled
Section titled “css.linter.enabled”启用 Biome 的 CSS 文件代码检查器。
¥Enables Biome’s linter for CSS files.
默认:
true¥Default:
true
{ "css": { "linter": { "enabled": false } }}css.assist.enabled
Section titled “css.assist.enabled”启用 Biome 对 CSS 文件的支持。
¥Enables Biome’s assist for CSS files.
默认:
true¥Default:
true
{ "css": { "assist": { "enabled": false } }}graphql
Section titled “graphql”应用于 GraphQL 文件的选项。
¥Options applied to the GraphQL files.
graphql.formatter.enabled
Section titled “graphql.formatter.enabled”启用 Biome 的 GraphQL 文件格式化程序。
¥Enables Biome’s formatter for GraphQL files.
默认:
false¥Default:
false
graphql.formatter.indentStyle
Section titled “graphql.formatter.indentStyle”GraphQL 文件的缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation for GraphQL files. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
graphql.formatter.indentWidth
Section titled “graphql.formatter.indentWidth”GraphQL 文件的缩进大小。
¥How big the indentation should be for GraphQL files.
默认:
2¥Default:
2
graphql.formatter.lineEnding
Section titled “graphql.formatter.lineEnding”GraphQL 文件的行尾类型。
¥The type of line ending for GraphQL files.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
graphql.formatter.lineWidth
Section titled “graphql.formatter.lineWidth”GraphQL 文件中单行可写入的字符数。
¥The amount of characters that can be written on a single line in GraphQL files.
默认:
80¥Default:
80
graphql.formatter.quoteStyle
Section titled “graphql.formatter.quoteStyle”表示字符串文字时使用的引号类型。它可以是 "single" 或 "double"。
¥The type of quote used when representing string literals. It can be "single" or "double".
默认:
"double"¥Default:
"double"
graphql.linter.enabled
Section titled “graphql.linter.enabled”启用 Biome 的 GraphQL 文件代码检查器。
¥Enables Biome’s linter for GraphQL files.
默认:
true¥Default:
true
graphql.assist.enabled
Section titled “graphql.assist.enabled”启用 Biome 对 GraphQL 文件的支持。
¥Enables Biome’s assist for GraphQL files.
默认:
true¥Default:
true
应用于 Grit 文件的选项。
¥Options applied to the Grit files.
grit.formatter.enabled
Section titled “grit.formatter.enabled”启用 Biome 的 Grit 文件格式化程序。
¥Enables Biome’s formatter for Grit files.
默认:
false¥Default:
false
grit.formatter.indentStyle
Section titled “grit.formatter.indentStyle”Grit 文件的缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation for Grit files. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
grit.formatter.indentWidth
Section titled “grit.formatter.indentWidth”Grit 文件的缩进大小。
¥How big the indentation should be for Grit files.
默认:
2¥Default:
2
grit.formatter.lineEnding
Section titled “grit.formatter.lineEnding”Grit 文件的行尾类型。
¥The type of line ending for Grit files.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
grit.formatter.lineWidth
Section titled “grit.formatter.lineWidth”Grit 文件中单行可写入的字符数。
¥The amount of characters that can be written on a single line in Grit files.
默认:
80¥Default:
80
grit.formatter.quoteStyle
Section titled “grit.formatter.quoteStyle”表示字符串文字时使用的引号类型。它可以是 "single" 或 "double"。
¥The type of quote used when representing string literals. It can be "single" or "double".
默认:
"double"¥Default:
"double"
grit.linter.enabled
Section titled “grit.linter.enabled”启用 Biome 的 Grit 文件代码检查器。
¥Enables Biome’s linter for Grit files.
默认:
true¥Default:
true
{ "grit": { "linter": { "enabled": false } }}grit.assist.enabled
Section titled “grit.assist.enabled”启用 Biome 对 Grit 文件的支持。
¥Enables Biome’s assist for Grit files.
默认:
true¥Default:
true
{ "grit": { "assist": { "enabled": false } }}html.experimentalFullSupportEnabled
Section titled “html.experimentalFullSupportEnabled”启用后,Biome 将完全支持类 HTML 语言。这些文件中嵌入语言的解析、格式化和代码检查保持一致。
¥When enabled, Biome enables full support for HTML-ish languages. Parsing, formatting and linting of embedded languages inside these files are consistent.
html.parser.interpolation
Section titled “html.parser.interpolation”启用对 .html 文件中双重文本表达式(例如 {{ expression }})的解析。
¥Enables the parsing of double text expressions such as {{ expression }} inside .html files.
默认:
false¥Default:
false
html.formatter.enabled
Section titled “html.formatter.enabled”启用 Biome 的 HTML 文件格式化程序。
¥Enables Biome’s formatter for HTML files.
默认:
false¥Default:
false
html.formatter.indentStyle
Section titled “html.formatter.indentStyle”HTML 文件的缩进样式。它可以是 "tab" 或 "space"。
¥The style of the indentation for HTML files. It can be "tab" or "space".
默认:
"tab"¥Default:
"tab"
html.formatter.indentWidth
Section titled “html.formatter.indentWidth”HTML 文件的缩进大小。
¥How big the indentation should be for HTML files.
默认:
2¥Default:
2
html.formatter.lineEnding
Section titled “html.formatter.lineEnding”HTML 文件的行尾类型。
¥The type of line ending for HTML files.
-
"lf",仅换行符(\n),在 Linux 和 macOS 以及 git repos 内部很常见;¥
"lf", Line Feed only (\n), common on Linux and macOS as well as inside git repos; -
"crlf",回车符 + 换行符(\r\n),在 Windows 上很常见;¥
"crlf", Carriage Return + Line Feed characters (\r\n), common on Windows; -
"cr",仅回车符(\r),很少使用。¥
"cr", Carriage Return character only (\r), used very rarely.
默认:
"lf"¥Default:
"lf"
html.formatter.lineWidth
Section titled “html.formatter.lineWidth”HTML 文件中单行可写入的字符数。
¥The amount of characters that can be written on a single line in HTML files.
默认:
80¥Default:
80
html.formatter.attributePosition
Section titled “html.formatter.attributePosition”HTML 元素中的属性位置样式。
¥The attribute position style in HTML elements.
-
"auto",属性会自动格式化,只有当它们符合某些条件时,它们才会折叠在多行中;¥
"auto", the attributes are automatically formatted, and they will collapse in multiple lines only when they hit certain criteria; -
"multiline",如果属性超过一个,则属性将折叠成多行。已使用。¥
"multiline", the attributes will collapse in multiple lines if more than 1 attribute is used.
默认:
"auto"¥Default:
"auto"
html.formatter.bracketSameLine
Section titled “html.formatter.bracketSameLine”是否将多行 HTML 标签的右括号紧贴最后一行末尾,而不是单独位于下一行。
¥Whether to hug the closing bracket of multiline HTML tags to the end of the last line, rather than being alone on the following line.
默认:
false¥Default:
false
html.formatter.whitespaceSensitivity
Section titled “html.formatter.whitespaceSensitivity”格式化 HTML(及其上级语言)时是否考虑空格敏感性。
¥Whether to account for whitespace sensitivity when formatting HTML (and its super languages).
默认:“css”
¥Default: “css”
-
"css":对于浏览器用户代理样式表中默认显示样式为 “inline” 的元素,格式化程序会将空格视为重要信息。¥
"css": The formatter considers whitespace significant for elements that have an “inline” display style by default in browser’s user agent style sheets. -
"strict":内容中的前导和尾随空格对所有元素都具有意义。¥
"strict": Leading and trailing whitespace in content is considered significant for all elements.如果存在空格,格式化程序应至少保留一个空格字符。否则,如果没有空格,则不应在
>之后或<之前添加空格。换句话说,如果没有空格,文本内容应该紧贴标签。¥The formatter should leave at least one whitespace character if whitespace is present. Otherwise, if there is no whitespace, it should not add any after
>or before<. In other words, if there’s no whitespace, the text content should hug the tags.文本紧贴标签的示例:
¥Example of text hugging the tags:
<b>content</b> -
"ignore":空格被视为无关紧要。格式化程序可以根据需要自由删除或添加空格。¥
"ignore": whitespace is considered insignificant. The formatter is free to remove or add whitespace as it sees fit.
html.formatter.indentScriptAndStyle
Section titled “html.formatter.indentScriptAndStyle”自 2.3 版本起:仅影响 .vue 和 .svelte 文件
¥Since 2.3: Only affects .vue and .svelte files
是否缩进 Vue 和 Svelte 文件中 <script> 和 <style> 标签的内容。目前,此功能不适用于纯 HTML 文件。
¥Whether to indent the content of <script> and <style> tags for Vue and Svelte files. Currently, this does not apply to plain HTML files.
默认:
false¥Default:
false
如果设置为 true,则 <script> 和 <style> 标签的内容将相对于其自身缩进一级。
¥When true, the content of <script> and <style> tags will be indented by one level relative to the tags.
<script>import Bar from "./Bar.vue"; import Bar from "./Bar.vue";</script>html.formatter.selfCloseVoidElements
Section titled “html.formatter.selfCloseVoidElements”空元素是否应该自闭合。默认从不。
¥Whether void elements should be self-closed. Defaults to never.
默认:
"never"¥Default:
"never"
-
"never":格式化程序会移除空元素中的斜杠/。¥
"never": The slash/inside void elements is removed by the formatter. -
"always":始终会在空元素中添加斜杠/。¥
"always": The slash/inside void elements is always added.
html.linter.enabled
Section titled “html.linter.enabled”启用 Biome 的 HTML 文件代码检查器。
¥Enables Biome’s linter for HTML files.
默认:
true¥Default:
true
html.linter.assist
Section titled “html.linter.assist”启用 Biome 对 HTML 文件的支持。
¥Enables Biome’s assist for HTML files.
默认:
true¥Default:
true
overrides
Section titled “overrides”模式列表。
¥A list of patterns.
使用此配置更改工具对某些文件的行为。
¥Use this configuration to change the behaviour of the tools for certain files.
当文件与覆盖模式匹配时,该模式中指定的配置将覆盖顶层配置。
¥When a file is matched against an override pattern, the configuration specified in that pattern will be override the top-level configuration.
模式的顺序很重要。如果文件可以匹配三种模式,则仅使用第一个模式。
¥The order of the patterns matter. If a file can match three patterns, only the first one is used.
overrides.<ITEM>.includes
Section titled “overrides.<ITEM>.includes”要应用自定义设置的文件列表 glob 模式。
¥A list of glob patterns of files for which to apply customised settings.
{ "overrides": [{ "includes": ["scripts/*.js"], // settings that should only apply to the files specified in the includes field. }]}overrides.<ITEM>.formatter
Section titled “overrides.<ITEM>.formatter”包含 顶层格式化程序 配置的选项,但不包含 ignore 和 include。
¥Includes the options of the top level formatter configuration, minus ignore and include.
¥Examples
例如,可以修改 glob 路径 generated/** 中包含的某些文件的格式化程序 lineWidth、indentStyle:
¥For example, it’s possible to modify the formatter lineWidth, indentStyle for certain files that are included in the glob path generated/**:
{ "formatter": { "lineWidth": 100 }, "overrides": [ { "includes": ["generated/**"], "formatter": { "lineWidth": 160, "indentStyle": "space" } } ]}overrides.<ITEM>.linter
Section titled “overrides.<ITEM>.linter”包含 顶层 linter 配置的选项,但不包含 ignore 和 include。
¥Includes the options of the top level linter configuration, minus ignore and include.
¥Examples
你可以禁用某些 glob 路径的某些规则,并禁用其他 glob 路径的 linter:
¥You can disable certain rules for certain glob paths, and disable the linter for other glob paths:
{ "linter": { "enabled": true, "rules": { "recommended": true } }, "overrides": [ { "includes": ["lib/**"], "linter": { "rules": { "suspicious": { "noDebugger": "off" } } } }, { "includes": ["shims/**"], "linter": { "enabled": false } } ]}overrides.<ITEM>.javascript
Section titled “overrides.<ITEM>.javascript”包含 顶层 javascript 配置的选项。允许你为某些文件覆盖 JavaScript 特定的设置。
¥Includes the options of the top level javascript configuration. Lets you override JavaScript-specific settings for certain files.
¥Examples
你可以更改某些文件夹中 JavaScript 文件的格式行为:
¥You can change the formatting behaviour of JavaScript files in certain folders:
{ "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } }, "overrides": [ { "includes": ["lib/**"], "javascript": { "formatter": { "quoteStyle": "double" } } } ]}overrides.<ITEM>.json
Section titled “overrides.<ITEM>.json”包含 顶层 json 配置的选项。允许你为某些文件覆盖 JSON 特定的设置。
¥Includes the options of the top level json configuration. Lets you override JSON-specific settings for certain files.
¥Examples
你可以为某些 JSON 文件启用解析功能:
¥You can enable parsing features for certain JSON files:
{ "linter": { "enabled": true, "rules": { "recommended": true } }, "overrides": [ { "includes": [".vscode/**"], "json": { "parser": { "allowComments": true, "allowTrailingCommas": true } } } ]}overrides.<ITEM>.[language]
Section titled “overrides.<ITEM>.[language]”包含顶层语言配置的选项。允许你为某些文件覆盖语言特定的设置。
¥Includes the options of the top level language configuration. Lets you override language-specific settings for certain files.
全局语法参考
Section titled “全局语法参考”¥Glob syntax reference
使用 Glob 模式匹配文件和文件夹的路径。Biome 支持以下 glob 语法:
¥Glob patterns are used to match paths of files and folders. Biome supports the following syntax in globs:
-
*匹配零个或多个字符。它无法匹配路径分隔符/。¥
*matches zero or more characters. It cannot match the path separator/. -
**递归匹配目录和文件。此序列必须作为完整路径组件使用,因此**a和b**均无效,会导致错误。连续两个以上的*字符序列也是无效的。¥
**recursively matches directories and files. This sequence must be used as an entire path component, so both**aandb**are invalid and will result in an error. A sequence of more than two consecutive*characters is also invalid. -
[...]匹配括号内的任何字符。还可以指定字符范围,按 Unicode 排序,例如[0-9]指定 0 到 9 之间的任何字符(含)。¥
[...]matches any character inside the brackets. Ranges of characters can also be specified, as ordered by Unicode, so e.g.[0-9]specifies any character between 0 and 9 inclusive. -
[!...]是[...]的否定,即它匹配括号中没有的任何字符。¥
[!...]is the negation of[...], i.e. it matches any characters not in the brackets. -
如果整个 glob 模式以
!开头,则称为否定模式。此 glob 仅当路径与 glob 不匹配时才匹配。否定模式不能单独使用,它们只能作为常规 glob 模式的例外。¥If the entire glob starts with
!, it is a so-called negated pattern. This glob only matches if the path doesn’t match the glob. Negated patterns cannot be used alone, they can only be used as exception to a regular glob. -
在判断是否包含某个文件时,Biome 也会考虑其父文件夹。这意味着,如果你想包含文件夹中的所有文件,则需要使用
/**后缀来匹配这些文件。如果你想忽略文件夹中的所有文件,则可以省略/**后缀。我们建议忽略不带尾部/**的文件夹,以避免不必要的遍历,并避免 Biome 从被忽略的文件夹中加载biome.json或.gitignore文件。¥When determining whether a file is included or not, Biome considers the parent folders too. This means that if you want to include all files in a folder, you need to use the
/**suffix to match those files. But if you want to ignore all files in a folder, you may do so without the/**suffix. We recommend ignoring folders without the trailing/**, to avoid needlessly traversing it, as well as to avoid the risk of Biome loading abiome.jsonor a.gitignorefile from an ignored folder.
一些示例:
¥Some examples:
-
dist/**匹配dist/文件夹及其中的所有文件。¥
dist/**matches thedist/folder and all files inside it. -
!dist会忽略dist/文件夹及其中的所有文件。¥
!distignores thedist/folder and all files inside it. -
**/test/**匹配任何名为test的文件夹下的所有文件,无论它们位于何处。例如dist/test,src/test.¥
**/test/**matches all files under any folder namedtest, regardless of where they are. E.g.dist/test,src/test. -
**/*.js匹配所有文件夹中所有以.js为扩展名的文件。¥
**/*.jsmatches all files ending with the extension.jsin all folders.
Biome v2.1 中文网 - 粤ICP备13048890号