Suppressions
このコンテンツはまだ日本語訳がありません。
Sometimes Biome is wrong about your code, or you have a good reason to break a rule. A suppression comment tells Biome to ignore a specific piece of code, and it records why, so the next person to read the code knows too.
If you want to turn off a rule everywhere, disable it in your configuration instead. Suppressions are for exceptions.
Write a suppression comment
Section titled “Write a suppression comment”A suppression comment starts with biome-ignore, followed by what to ignore and a reason:
// biome-ignore lint/suspicious/noDebugger: needed to debug the payment flowdebugger;The comment has three parts:
biome-ignoredecides how much code it covers. See Choose what to cover.- What to ignore, such as
lint/suspicious/noDebugger. See Choose what to ignore. - The reason, after the colon. It is required, so write something that helps your teammates.
Comments use the syntax of each language, such as /* biome-ignore ... */ in CSS or <!-- biome-ignore ... --> in HTML.
Choose what to cover
Section titled “Choose what to cover”The next line
Section titled “The next line”biome-ignore covers the code that comes right after the comment. In the following example, only the first debugger statement is ignored:
// biome-ignore lint/suspicious/noDebugger: reasondebugger;debugger;A whole file
Section titled “A whole file”biome-ignore-all covers the whole file, which makes it useful for generated code. Place it at the top of the file:
// biome-ignore-all lint/suspicious/noDebugger: this file is generateddebugger;debugger;If a biome-ignore-all comment is anywhere else, Biome reports it as unused.
A range of lines
Section titled “A range of lines”biome-ignore-start and biome-ignore-end cover everything in between. Every start comment needs a matching end comment:
// biome-ignore-start lint/suspicious/noDoubleEquals: legacy comparison logica == b;c == d;// biome-ignore-end lint/suspicious/noDoubleEquals: legacy comparison logice == f;Here, lines 2 and 3 are ignored, but line 5 is still reported. Ranges for different rules can overlap.
Choose what to ignore
Section titled “Choose what to ignore”After biome-ignore, write the category of the tool you want to silence. Add a group and a rule name, separated by slashes, to be more specific:
| Comment | What it ignores |
|---|---|
biome-ignore lint: <reason> |
Every lint rule |
biome-ignore lint/suspicious: <reason> |
Every rule in the suspicious group |
biome-ignore lint/suspicious/noDebugger: <reason> |
Only the noDebugger rule |
biome-ignore assist/source/useSortedKeys: <reason> |
Only the useSortedKeys assist action |
biome-ignore format: <reason> |
The formatter |
biome-ignore syntax: <reason> |
Syntax diagnostics |
biome-ignore lint/plugin: <reason> |
Every plugin |
biome-ignore lint/plugin/myPlugin: <reason> |
Only the myPlugin.grit GritQL plugin |
biome-ignore lint/plugin/myRule: <reason> |
Only the myRule rule exported by a JavaScript plugin |
Prefer the most specific form, so that you do not hide other problems by accident. If you are not sure what to write, copy the diagnostic category shown on the rule’s documentation page or in the diagnostic itself.
A few rules also let you ignore a single value by adding it in parentheses, for example lint/correctness/useExhaustiveDependencies(user) ignores only the user dependency. The documentation page of the rule tells you if it supports this.
Suppress from your editor
Section titled “Suppress from your editor”When your editor shows a Biome diagnostic, its quick fixes include actions that insert a suppression comment for you, either for the next line or for the whole file.
If you never want to see these actions, you can turn them off. Use source.suppressRule.inline.biome for the next-line suppression:
{ "editor.codeActionsOnSave": { "source.suppressRule.inline.biome": "never" }}{ "code_actions_on_format": { "source.suppressRule.inline.biome": false }}source.suppressRule.inline.biome And source.suppressRule.topLevel.biome for the whole-file suppression:
{ "editor.codeActionsOnSave": { "source.suppressRule.topLevel.biome": "never" }}{ "code_actions_on_format": { "source.suppressRule.topLevel.biome": false }}source.suppressRule.topLevel.biome Suppress every existing violation
Section titled “Suppress every existing violation”When you adopt Biome in an existing project, or enable a new rule, you might get hundreds of diagnostics at once. Instead of fixing them all before you can merge, you can suppress every current violation and fix them over time:
npx biome lint --suppress --reason="TODO: fix after adopting Biome"pnpm biome lint --suppress --reason="TODO: fix after adopting Biome"bunx biome lint --suppress --reason="TODO: fix after adopting Biome"deno run -A npm:@biomejs/biome lint --suppress --reason="TODO: fix after adopting Biome"yarn biome lint --suppress --reason="TODO: fix after adopting Biome"biome lint --suppress --reason="TODO: fix after adopting Biome"Biome adds a biome-ignore comment with your reason above each violation. New code is checked normally, and you can search for the reason to find what is left to fix.
Clean up unused suppressions
Section titled “Clean up unused suppressions”When a suppression comment no longer hides anything, for example because someone fixed the code, Biome reports it as unused. Remove the comment to keep your code clean.
© 2023-present Biome developers and contributors.