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

📎 Make code fix kind configurable #2882

Closed
Conaclos opened this issue May 16, 2024 · 0 comments · Fixed by #2892
Closed

📎 Make code fix kind configurable #2882

Conaclos opened this issue May 16, 2024 · 0 comments · Fixed by #2892
Assignees
Labels
A-Analyzer Area: analyzer A-Linter Area: linter S-Feature Status: new feature to implement

Comments

@Conaclos
Copy link
Member

Conaclos commented May 16, 2024

Description

Users have asked several times for a way to disable a rule fix or to upgrade a rule fix from unsafe to safe. Some users would also like a way to downgrade a fix from safe to unsafe.

Disabling a code fix is particularly useful if a user encounters a bug with the code fix.
The user can then disable the rule and continue to use --apply/--apply-unsafe.
Upgrading a code fix to safe has the advantage of allowing users to automatically fix a rule in an IDE.
Conversely, downgrading a rule allows you to disable auto-fixing in the IDE.

I propose to add a new field fix to each rule configuration.
fix will take a value among safe, unsafe and none.
If the field is not set, then the default fix kind is the kind declared in the rule.
This field has no effect for rules without a code fix. Ideally we should output an error for such rules.

Here is an example, where we disable the code fix of noUnusedVariables, where we downgrade the code fix useConst of and upgrade the code fix of useTemplate

{
  "linter": {
    "rules": {
      "correctness": {
        "noUnusedVariables": {
          "level": "error",
          "fix": "none"
        },
        "style": {
          "useConst": {
            "level": "warn",
            "fix": "unsafe"
          },
          "useTemplate": {
            "level": "warn",
            "fix": "safe"
          }
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analyzer Area: analyzer A-Linter Area: linter S-Feature Status: new feature to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants