Skip to content

语言支持

图例:

¥Legend:

  • ✅ 支持

    ¥✅: Supported

  • 🚫 未进行中

    ¥🚫: Not in progress

  • ⌛️ 进行中

    ¥⌛️: In progress

  • ⚠️ 部分支持(有一些注意事项)

    ¥⚠️: Partially supported (with some caveats)

语言解析格式化Linting
JavaScript
TypeScript
JSX
TSX
JSON
JSONC
HTML⌛️⌛️🚫
Vue⚠️⚠️⚠️
Svelte⚠️⚠️⚠️
Astro⚠️⚠️⚠️
CSS✅️✅️✅️
YAML⌛️🚫🚫
GraphQL✅️✅️✅️
Markdown⌛️🚫🚫

¥JavaScript support

Biome 支持该语言的 ES2024 版本。

¥Biome supports the ES2024 version of the language.

Biome 仅支持官方语法。当提案达到 第 3 阶段 时,团队开始开发新语法。

¥Biome supports only the official syntax. The team starts development of the new syntax when a proposal reaches Stage 3.

¥TypeScript support

Biome 支持 TypeScript 版本 5.6。

¥Biome supports TypeScript version 5.6.

¥JSONC Support

JSONC 代表 “带注释的 JSON。“。这种格式被 VS CodeTypeScriptBabel 等各种工具广泛使用,因为它允许用户在配置文件中添加注释。但是,由于 JSONC 并不是一个严格定义的标准,因此不同的工具在处理 JSONC 文件中的尾随逗号方面存在一些差异。为了适应这一点,Biome 没有为 JSONC 提供专用的语言配置。相反,我们通过 json.parser.allowCommentsjson.parser.allowTrailingCommasjson.formatter.trailingCommas 等选项增强了 JSON 解析和格式化功能。这种方法使 Biome 能够有效地支持不同变体的 JSON 文件。

¥JSONC stands for “JSON with Comments.” This format is widely used by various tools like VS Code, TypeScript, Babel, etc. because it lets users add comments to configuration files. However, since JSONC isn’t a strictly defined standard, there’s some variation in how different tools handle trailing commas in JSONC files. To accommodate this, Biome doesn’t provide a dedicated language configuration for JSONC. Instead, we’ve enhanced our JSON parsing and formatting capabilities with options like json.parser.allowComments, json.parser.allowTrailingCommas, and json.formatter.trailingCommas. This approach allows Biome to effectively support different variants of JSON files.

对于扩展名为 .jsonc 的文件或根据 语言标识符 标识为 jsonc 的文件,Biome 会自动应用以下默认设置来解析和格式化它们:

¥For files with an extension name of .jsonc or those identified as jsonc according to the language identifier, Biome automatically applies the following default settings for parsing and formatting them:

  • json.parser.allowCommentstrue

  • json.parser.allowTrailingCommastrue

  • json.formatter.trailingCommasnone

请注意,一些知名文件(如 tsconfig.json.babelrc)不使用 .jsonc 扩展,但仍允许注释和尾随逗号。而其他的,例如 .eslintrc.json,只允许注释。Biome 能够识别这些文件并相应地调整 json.parser.allowTrailingCommas 选项以确保正确解析它们。

¥Please note, some well-known files like tsconfig.json and .babelrc don’t use the .jsonc extension but still allow comments and trailing commas. While others, such as .eslintrc.json, only allow comments. Biome is able to identify these files and adjusts the json.parser.allowTrailingCommas option accordingly to ensure they are correctly parsed.

本节 提供了 Biome 可以识别的知名文件的完整列表。

¥This section gives the full list of well-known files that Biome can recognize.

¥HTML super languages support

1.6.0 版本开始,这些语言部分受支持。Biome 会随着时间的推移而变得更好,它将提供更多选项来调整你的项目。就目前而言,有一些期望和限制需要考虑:

¥As of version 1.6.0, these languages are partially supported. Biome will get better over time, and it will provide more options to tweak your project. As for today, there are some expectations and limitations to take in consideration:

  • 对于 .astro 文件,仅支持文件的 frontmatter 部分。

    ¥For .astro files, only the frontmatter portion of the file is supported.

  • 对于 .vue.svelte 文件,仅支持文件的 <script> 标签部分。

    ¥For .vue and .svelte files, only the <script> tags portion of the file is supported.

  • 诊断将仅显示属于上述部分的代码框架。

    ¥Diagnostics will only show code frames that belong to the portions mentioned above.

  • 格式化 .vue.svelte 文件时,JavaScript/TypeScript 代码的缩进将从头开始。

    ¥When formatting .vue and .svelte files, the indentation of the JavaScript/TypeScript code will start from the beginning.

    file.vue
    <script>
    import Component from "./Component.vue";
    import Component from "./Component.vue";
    </script>
  • 在对 .svelte.astro.vue 文件进行 linting 时,建议关闭一些附加规则以防止编译器错误。为此使用选项 overrides

    ¥When linting .svelte, .astro or .vue files, it’s advised to turn off few additional rules to prevent compiler errors. Use the option overrides for that:

    {
    "overrides": [
    {
    "include": ["*.svelte", "*.astro", "*.vue"],
    "linter": {
    "rules": {
    "style": {
    "useConst": "off",
    "useImportType": "off"
    }
    }
    }
    }
    ]
    }