-
-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(analyzer): top level suppression #4306
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
59db571
feat(analyzer): top-level suppressions
ematipico 2342552
remove test that doesn't emit diagnostics
ematipico 9204c57
add top-level action as additional action
ematipico 569dc93
test: update test cases for LSP actions
ematipico f08ce1d
format
ematipico 04d616b
codegen
ematipico fa66c73
update tests
ematipico 5ef54b0
update CSS tests
ematipico 3bcd86d
update package.json files
ematipico d1c6e89
rebase and update graphql suppressions
ematipico 9d67ec2
format, dah
ematipico a8be40c
code action breaking change
ematipico 716819c
fix issue in the suppression action
ematipico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new API was created to suppose this new diagnostic: https://github.com/biomejs/biome/pull/4306/files#diff-6b7a758a5c6e91dd2722ccc423ad136ff4e811311c0d49b80c659d61cc54e2a6
Neat :)