-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Change Request: Ability to disable autofixes on a per-rule basis #18696
Comments
This is probably the most likely approach to such a feature. I agree that this would be useful, but I think there are a bunch of considerations we need to put into this, so we'll require an RFC. Keep in mind that we are no longer making changes to the v8.x release line, so any changes would end up in the v9.x line and only in flat config format. |
Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update. |
Where / how could I get the ball rolling on this ?
That's perfectly acceptable. |
ESLint version
8.56.0
What problem do you want to solve?
Some rules provide autofixing, which is great, but can sometimes be broken or otherwise simply unwanted for various reasons.
Unsafe autofixes should be suggestions, and broken fixes should be reported, but ESLint is a large ecosystem where some very useful plugins are not always actively maintained. Even then, wanting to disable an autofix for project-specific or personal reasons could still happen.
What do you think is the correct solution?
I'd like ESLint to provide a way to configure rules to disable their autofixing. I can immediately think of two approaches:
Similar to how Ruff (https://docs.astral.sh/ruff/settings/#lint_unfixable) does it, a top-level key to specify which rules to not autofix would be imo the least disruptive and forward/backwards compatible. It should be overridable (in the
overrides
section), and picked up when extending a configuration.Another approach I can think of is to encode that in the rule config itself. Something like
"my-plugin/my-rule": "[{severity: "error", autofix: False}, {...otherConfigs}]"
but it's harder to commit to such a change, and means that any config extension needs to reconfigure the rule correctly just to disable autofixing (which is already an issue when someone wants to set a pre-configured rule as warning for example)Participation
Additional comments
https://www.npmjs.com/package/eslint-plugin-no-autofix is a tool that exists to currently work around this limitation of ESLint, but it is not perfect.
eslint-plugin-no-autofix
crashes when run onpre-commit.ci
aladdin-add/eslint-plugin#98@eslint-community/eslint-comments/no-unused-disable
option to disable autofix eslint-community/eslint-plugin-eslint-comments#234I searched for a similar issue but couldn't find any. So hopefully this isn't an already refused proposal 🤞
The text was updated successfully, but these errors were encountered: