Skip to content

诊断

Biome 的诊断信息非常丰富,它们通常会提供你了解错误并修复错误所需的所有信息。

¥Biome’s diagnostics are full of information, and they usually provide all the information you need to understand errors, and fix them.

诊断不仅用于错误,还用于提供结构化信息、警告和提示。信息

¥Diagnostics aren’t only used for errors, but they are also used to provide structured information, warnings and tips.information

此页面提供了诊断可以包含的所有信息的细分。了解诊断的所有不同部分可以帮助你识别重要部分以及它们背后的一些 “secrets”。

¥This page provide a break down of all the information that a diagnostic can contain. Learning all the different parts of a diagnostic can help you to identify the important parts, and some “secrets” behind them.

¥Diagnostic severity

诊断的严重性会影响 CLI。例如,错误诊断将强制 CLI 以错误代码退出。

¥The severity of the diagnostic can affect the CLI. For example, error diagnostics will force the CLI to exit with an error code.

¥Fatal

错误诊断有红色文本。Biome 内部发生意外错误时通常会发出致命诊断。与错误相比,它们具有 致命标签

¥Error diagnostics have red text. Fatal diagnostics are usually emitted when an unexpected error occurred inside Biome. Compared to errors, they have the fatal tag.


 FATAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  
   Biome exited as this error could not be handled and resulted in a fatal error. Please report it if necessary.
  

¥Error

错误诊断有红色文本。通常,应该解决这些问题,因为它们在 CLI 遇到时会发出错误代码。

¥Error diagnostics have red text. Usually, they should be addressed because they will emit an error code when encountered by the CLI.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Warning

警告诊断有黄色文本。通常,应该解决这些问题。警告不是阻止程序,它们不会阻止 CLI 工作。

¥Warning diagnostics have yellow text. Usually, they should be addressed. Warnings are not blockers, and they won’t stop the CLI from working.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Information

信息诊断具有绿色文本。它们提供有用的信息,并且它们不是为了阻止 CLI。

¥Information diagnostics have green text. They provide useful information and they aren’t meant to block the CLI.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Diagnostic tags

标签可以看作是附加到诊断的元数据,它们可以以不同的方式影响客户端。

¥Tags can be seen as metadata attached to a diagnostic, and they can affect the clients in different ways.

¥Verbose

详细诊断通常是隐藏的。通过 CLI,你可以使用 --verbose 选项显示这些诊断。

¥Verbose diagnostics are usually hidden. Via CLI, you can show these diagnostics using the --verbose option.


 VERBOSE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Internal

当发生内部错误时,将发出内部诊断。通常鼓励用户在发现错误时提交错误。

¥Internal diagnostics are emitted when an internal error occurred. Users are usually encourage to file a bug when they see one.


 INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  
   This diagnostic was derived from an internal Biome error. Potential bug, please report it if necessary.
  

¥Fixable

可修复诊断针对用户可以修复的特定情况发出。它们通常用于具有代码操作的 lint 诊断。

¥Fixable diagnostics are emitted for those particular situations that can be fixed by the user. They are usually used for lint diagnostics that have a code action.


 FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Deprecated

包含已弃用代码的诊断

¥Diagnostics that contain code that is deprecated


 DEPRECATED  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Diagnostic category

类别服务于组诊断。类别可以可选地具有链接,例如属于 lint 规则的类别,如下例所示。

¥The category serves the group diagnostics. Optionally, a category can a have a link, for example for categories that belong to lint rules, like in the example below.

¥Simple category

此诊断属于“check”类别,这意味着它在执行 check 命令时发出:

¥This diagnostic belongs to the category “check”, which means that it is emitted when executing the check command:


check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Category with link

此诊断属于“lint/a11y/noAccessKey ”类别。该链接将用户带到 lint 规则 noAccessKey 的网页。

¥This diagnostics belongs to the category “lint/a11y/noAccessKey ”. The link takes the user to the webpage of the lint rule noAccessKey.


lint/a11y/noAccessKey ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Diagnostic location

诊断可以有 “location”。位置由三个可选部分组成:

¥Diagnostics can have a “location”. A location is made by three, optional, parts:

  • 资源,即发出诊断的来源;

    ¥a resource, which is the origin that emitted the diagnostic;

  • 文件的源代码;

    ¥source code of the file;

  • 跨度(或文本范围),通常是文件内的行和列。

    ¥a span (or text range), usually the line and column inside the file.

¥Diagnostic file path

文件路径通常是你看到的第一条信息,位于诊断的左上角。

¥The file path is usually the first information you see, at the top left of the diagnostic.


path/to/file.js ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  

¥Diagnostic source code

这显示了与文件关联的源代码的显示方式。请注意,未显示行和列。

¥This shows how the source code associated to a file is shown. Notice that the line and columns aren’t shown.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  
  > 1 │ Some source code
        ^^^^^
  

¥Diagnostic line and column

行和列通常打印在文件路径旁边,并且只有当它与某些源代码相关联时才会显示。

¥Line and column is usually printed beside the file path, and it’s shown only when there’s some source code associated to it.


path/to/file.txt:1:6 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  
  > 1 │ Some source code
        ^^^^^^
  

当诊断打印在 IDE 的终端内时,你可以单击 path/to/file.js:2:2,IDE 将打开相关文件,并将光标放在跨度的开头。

¥When the diagnostics are printed inside the terminal of an IDE, you can click path/to/file.js:2:2, and the IDE will open the relative file, and place cursor at the beginning of the span.


path/to/file.js:2:2 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  
    1 │ function name() {
  > 2 │ 	return 'lorem'
   	^^^^^^^^^^^^^^
    3 │ }
  

¥Diagnostic advices

此外,我们的诊断可以存储建议。建议是可以附加在原始消息之后的附加消息。

¥Additionally, our diagnostics can store advices. Advices are additionally messages that can be appended after the original message.

这些建议有不同的种类和形状。通常,建议总是被打印,除非它们是详细的建议。

¥These advices comes with different kinds and shapes. Usually, advices are always printed, unless they are verbose advices.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   This is the message of the diagnostic. It will appear in different colours based on the severity of the diagnostic.
  
   This log is an error.
  
   This log is a warning
  
   This log is an information
  
  This log doesn't have any category. Below, you'll have a command
  
  $ biome command
  
  Below, a group.
  
  I am a group
  
     First message of a group.
    
     Second message of a group.
    
  Below, a list.
  
  - First item
  - Second item
  
  Below, a diff.
  
  - Old·code
  + New·code
  
  Below, a code frame.
  
  > 1 │ Lorem
   ^^^
    2 │ Ipsum