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",
]
}
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.ruffcode actions on save.Notes
contextfield asCodeActionTriggerKind.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.rulesbut 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
includeandexcludefield like so:{ "ruff.codeActionsOnSave.rules": { "include": [], "exclude": [], } }Or, allow a negation pattern using
!:{ "ruff.codeActionsOnSave.rules": [ "!F401", ] }