-
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analyzer): top level suppression (#4306)
- Loading branch information
Showing
65 changed files
with
2,367 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
cli: minor | ||
--- | ||
|
||
# New top-level suppression for the analyzer | ||
|
||
The Biome analyzer now supports a new top-level suppression. These suppression have to be placed at the top of the file, and they must be followed by two newlines (`\n\n\`). | ||
|
||
The analyzer rules specified inside the block comment will be suppressed for the whole file. | ||
|
||
In the example, we suppress the rules `lint/style/useConst` and `lint/suspicious/noDebugger` for the whole file: | ||
|
||
```js | ||
// main.js | ||
/** | ||
* biome-ignore lint/style/useConst: i like let | ||
* biome-ignore lint/suspicious/noDebugger: needed now | ||
*/ | ||
|
||
let path = "/path"; | ||
let _tmp = undefined; | ||
debugger | ||
``` | ||
|
||
In this other example, we suppress `lint/suspicious/noEmptyBlock` for a whole CSS file: | ||
|
||
```css | ||
/** | ||
/* biome-ignore lint/suspicious/noEmptyBlock: it's fine to have empty blocks | ||
*/ | ||
|
||
a {} | ||
span {} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
cli: major | ||
--- | ||
|
||
# Remove support for legacy suppressions | ||
|
||
Biome used to support "legacy suppressions" that looked like this: | ||
|
||
```js | ||
// biome-ignore lint(style/useWhile): reason | ||
``` | ||
|
||
This format is no longer supported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
cli: major | ||
--- | ||
|
||
# Remove the code action `quickfix.suppressRule` | ||
|
||
The code action `quickfix.suppressRule` was removed in favour of two new code actions: | ||
|
||
- `quickfix.suppressRule.inline.biome`: a code action that adds a suppression comment for each violation. | ||
- `quickfix.suppressRule.topLevel.biome`: a code action that adds a suppression comment at the top of the file which suppresses a rule for the whole file. | ||
|
||
|
||
Given the following code | ||
```js | ||
let foo = "one"; | ||
debugger | ||
``` | ||
|
||
The code action `quickfix.suppressRule.inline.biome` will result in the following code: | ||
```js | ||
// biome-ignore lint/style/useConst: <explanation> | ||
let foo = "one"; | ||
// biome-ignore lint/suspicious/noDebugger: <explanation> | ||
debugger | ||
``` | ||
|
||
The code action `quickfix.suppressRule.topLevel.biome`, instead, will result in the following code: | ||
```js | ||
/** biome-ignore lint/suspicious/noDebugger: <explanation> */ | ||
/** biome-ignore lint/style/useConst: <explanation> */ | ||
|
||
let foo = "one"; | ||
debugger; | ||
``` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.