-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Arend van Beelen jr. <[email protected]> Co-authored-by: Carson McManus <[email protected]>
- Loading branch information
1 parent
39edbf2
commit f281e8a
Showing
80 changed files
with
1,653 additions
and
1,029 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,55 @@ | ||
--- | ||
cli: minor | ||
--- | ||
|
||
# Biome assist | ||
|
||
Biome assist is a new feature of the Biome analyzer. The assist is meant to provide **actions**. Actions differ from linter rules in that they aren't meant to signal errors. | ||
|
||
The assist will provide code actions that users can opt into via configuration or via IDEs/editors, using the Language Server Protocol. | ||
|
||
The assist **is enabled by default**. However, you can turn if off via configuration: | ||
|
||
```json | ||
{ | ||
"assist": { | ||
"enabled": false | ||
} | ||
} | ||
``` | ||
|
||
You can turn on the actions that you want to use in your configuration. For example, you can enable the `useSortedKeys` action like this: | ||
|
||
```json | ||
{ | ||
"assist": { | ||
"actions": { | ||
"source": { | ||
"useSortedKeys": "on" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Alternatively, IDE/editor users can decide which action to apply on save *directly from the editor settings*, as long as the assist is enabled. | ||
|
||
For example, in VS Code you can apply the `useSortedKeys` action when saving a file by adding the following snippet in `settings.json`: | ||
|
||
```json | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.biome.useSortedKeys": "explicit" | ||
} | ||
} | ||
``` | ||
|
||
In Zed, you can achieve the same by adding the following snippet in `~/.config/zed/settings.json`: | ||
|
||
```json | ||
{ | ||
"code_actions_on_format": { | ||
"source.biome.useSortedKeys": true | ||
} | ||
} | ||
``` |
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,37 @@ | ||
--- | ||
cli: minor | ||
--- | ||
|
||
# Code actions via IDE/editor | ||
|
||
Biome users can now configure code actions from linter rules as well as assist actions directly in the settings of their IDE/editor. | ||
|
||
For example, let's consider the lint rule [`noSwitchDeclarations`](https://biomejs.dev/linter/rules/no-switch-declarations/), which has an unsafe fix. | ||
Previously, if you wanted to use this rule, you were "forced" to enable it via configuration, and if you wanted to apply its fix when you saved a file, you were forced to mark the fix as safe: | ||
|
||
```json | ||
{ | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noSwitchDeclarations": { | ||
"level": "error", | ||
"fix": "safe" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Now, you can benefit from the code action without making the fix safe for the entire project. IDEs and editors that are LSP compatible allow to list a series of "filters" or code actions that can be applied on save. In the case of VS Code, you will need to add the following snippet in the `settings.json`: | ||
|
||
```json | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"quickfix.biome.correctness.noSwitchDeclarations": "explicit" | ||
} | ||
} | ||
``` | ||
|
||
Upon save, Biome will inform the editor the apply the code action of the rule `noSwitchDeclarations`. |
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
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
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
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.