Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Server setting to run subset of rules for "Fix All" code action #12709

Open
dhruvmanila opened this issue Aug 6, 2024 · 1 comment
Open

Server setting to run subset of rules for "Fix All" code action #12709

dhruvmanila opened this issue Aug 6, 2024 · 1 comment
Labels
configuration Related to settings and configuration needs-design Needs further design before implementation server Related to the LSP server

Comments

@dhruvmanila
Copy link
Member

Discussion: #12674

It would be useful to provide a server (and VS Code extension) setting to allow including / excluding only a subset of rules to be fixed when running the source.fixAll.ruff code actions on save.

Notes

  • It's important that this is only considered when running the code action on save and not when running it manually. This is present in the request payload under the context field as CodeActionTriggerKind.
  • This is a filter which is applied on top of the rule selection as done via a config file / server setting.

For prior art, refer to eslint.codeActionsOnSave.rules. This allows for patterns and allows negation as well. Search for "eslint.codeActionsOnSave.rules" in https://github.com/microsoft/vscode-eslint#settings-options for examples.

We could introduce a similar option ruff.codeActionsOnSave.rules but I don't think we should allow for patterns in it. Our rule selection allows for shorter codes that negates the need for * pattern. But, we do need to consider about a config to exclude rules instead of including them.

One option would be to provide both include and exclude field like so:

{
	"ruff.codeActionsOnSave.rules": {
		"include": [],
		"exclude": [],
	}
}

Or, allow a negation pattern using !:

{
	"ruff.codeActionsOnSave.rules": [
		"!F401",
	]
}
@dhruvmanila dhruvmanila added configuration Related to settings and configuration server Related to the LSP server needs-design Needs further design before implementation labels Aug 6, 2024
@dhruvmanila
Copy link
Member Author

Cross linking from the discussion thread: #15991 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
configuration Related to settings and configuration needs-design Needs further design before implementation server Related to the LSP server
Projects
None yet
Development

No branches or pull requests

1 participant