Skip to content
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

☂️ Analyzer assists #3178

Open
ematipico opened this issue Jun 11, 2024 · 4 comments
Open

☂️ Analyzer assists #3178

ematipico opened this issue Jun 11, 2024 · 4 comments
Labels
A-Analyzer Area: analyzer S-Feature Status: new feature to implement

Comments

@ematipico
Copy link
Member

ematipico commented Jun 11, 2024

Description

Issue to track a new feature called Analyzer assists (or actions).

Assists (code actions)

Assists/Action are a concept of the LSP spect. Code actions are usually opt-in, and the user can decide to apply these actions using the UI of a client.

Assists are code actions that can be categorized as refactor opportunities, extractions, etc.

We will borrow this concept and make ours inside the Biome LSP, and we will provide a way to enforce it in the CLI.

Possible configuration:

{
	"assists": {
		"enabled": true, // enables assist across the board
		"enforce": true // the CLI will check if the assists are applied to the source. If not, it fails
	},
	"json": {
		"assists": {
			"useSortKeys": "on" // same naming convention of lint rules, yay!
		}
	},
	"javascript": {
		"assists": { 
			"enabled": false // don't use assists inside javascript files
		}
	}
}

Assists can be opted in from the LSP too. For example, a LSP client can send the following code to enable useSortKeys from the previous example, in VSCode:

{
  "editor.codeActionsOnSave":{
    "source.useSortKeys.biome": "explicit"
  }
}

Or, using zed:

{
  "code_actions_on_format": {
    "source.useSortKeys.biome": true
  }
}

Example of assists:

Why not lint rules?

The goal of the Biome linter is to catch possible bugs, enforce some idiomatic coding pattern, or propose some conventions. The Biome linter isn't meant to enforce stylistic decision, because that's what the Biome formatter is meant for.

Why not a formatter?

The Biome formatter is meant to enforce a coding style that matches Prettier as much as possible, and to reduce the diffing inside the PRs. An assists like sorting could have a huge impact on the diffing of PR, that's why assists aren't meant for a formatter.

@ematipico ematipico added A-Analyzer Area: analyzer S-Feature Status: new feature to implement labels Jun 11, 2024
@lishaduck
Copy link

lishaduck commented Jun 13, 2024

Is #1274 a candidate for an assist? It doesn't feel like a lint rule, but editing strings is beyond the scope of a formatter.

@ematipico
Copy link
Member Author

I think it could be a good candidate for assist, yes!

@lishaduck
Copy link

I think it could be a good candidate for assist, yes!

Cool. I just wanted to make sure I understood what this was. Have a nice day!

@Netail
Copy link
Contributor

Netail commented Jun 21, 2024

As discussed on Discord, an attribute sorter for typescript interfaces would be a nice addition to the sorting LSPs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analyzer Area: analyzer S-Feature Status: new feature to implement
Projects
None yet
Development

No branches or pull requests

3 participants