Assist
Biome Assist offers a series of actions meant to improve code quality and DX of the users.
Contrary to linter rules, assist actions must not change the semantics of a program, they might not provide a diagnostic, and they always provide a code fix. Their usage fits more editors and IDEs, and they might include sorting of properties or fields, simplification of binary expressions, refactor opportunities and more. However, it’s possible to enforce the use of assist actions even with the CLI. The assist has 4 actions.
Assist actions are very close to LSP code actions in semantics, and they are divided in groups.
Biome assist is enabled by default. In the following example, you can enable the assist and enable the action useSortedKeys
:
{ "assist": { "enabled": true, "actions": { "source": { "useSortedKeys": "on" } } }}
Enforce assist actions via CLI
Section titled Enforce assist actions via CLIAssist actions can be enforced via CLI via check
command:
npx @biomejs/biome check
yarn biome check
pnpm biome check
bunx biome check
deno run -A npm:@biomejs/biome check
However, the check
is meant for running multiple tools at once, so if you want to check only the assist actions, you should run:
npx @biomejs/biome check --formatter-enabled=false --linter-enabled=false
yarn biome check --formatter-enabled=false --linter-enabled=false
pnpm biome check --formatter-enabled=false --linter-enabled=false
bunx biome check --formatter-enabled=false --linter-enabled=false
deno run -A npm:@biomejs/biome check --formatter-enabled=false --linter-enabled=false
Use assist actions in your IDE
Section titled Use assist actions in your IDEIf you have an LSP-compatible IDE, then you can configure Biome to execute particular actions on save. Each assist action has a particular code called “code action”. While the majority of names follow the same pattern, there might be few exceptions (e.g. organizeImports
), so refer to the documentation page of each action to learn to associated code.
For example, the action useSortedKeys
has a code action called source.action.useSortedKeys.biome
. If you use VSCode, you can copy this code and place it in the editor.codeActionsOnSave
section, and Biome will apply it when you save a document:
{ "code_actions_on_format": { "source.action.useSortedKeys.biome": true, }}
{ "editor.codeActionsOnSave": { "source.action.useSortedKeys.biome": "explicit", }}
source.action.useSortedKeys.biome
Groups
Section titled GroupsSource
Section titled SourceThis group represents those actions that can be safely applied to a document upon saving. They don’t change the semantics of a program.