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

Change Request: Ability to disable autofixes on a per-rule basis #18696

Open
1 task
Samuel-Therrien-Beslogic opened this issue Jul 17, 2024 · 3 comments
Open
1 task
Labels
core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint needs design Important details about this change need to be discussed

Comments

@Samuel-Therrien-Beslogic

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:

  1. 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.

  2. 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

  • I am willing to submit a pull request for this change.

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.

  1. It is an extra third-party dependency, with its own potential maintenance issues (having to keep up with ESLint, separate dependencies that can fall out of date, obsolete, unsecure, etc.)
  2. It may not work in all environments. For example, pre-commit.ci: bug report: eslint-plugin-no-autofix crashes when run on pre-commit.ci aladdin-add/eslint-plugin#98
  3. It may not work correctly with all third-party rules: @eslint-community/eslint-comments/no-unused-disable option to disable autofix eslint-community/eslint-plugin-eslint-comments#234

I searched for a similar issue but couldn't find any. So hopefully this isn't an already refused proposal 🤞

@Samuel-Therrien-Beslogic Samuel-Therrien-Beslogic added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint labels Jul 17, 2024
@nzakas
Copy link
Member

nzakas commented Jul 18, 2024

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.

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.

@nzakas nzakas added the needs design Important details about this change need to be discussed label Jul 18, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Aug 17, 2024
@Samuel-Therrien-Beslogic
Copy link
Author

Samuel-Therrien-Beslogic commented Aug 22, 2024

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.

Where / how could I get the ball rolling on this ?
Edit: I think I found it https://github.com/eslint/rfcs

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.

That's perfectly acceptable.

@github-actions github-actions bot removed the Stale label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint needs design Important details about this change need to be discussed
Projects
Status: Waiting for RFC
Development

No branches or pull requests

2 participants