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: Support applying suggestions #18264

Closed
1 task done
DMartens opened this issue Apr 4, 2024 · 1 comment
Closed
1 task done

Change Request: Support applying suggestions #18264

DMartens opened this issue Apr 4, 2024 · 1 comment
Labels
core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint

Comments

@DMartens
Copy link
Contributor

DMartens commented Apr 4, 2024

ESLint version

HEAD

What problem do you want to solve?

There is no currently no way to apply suggestions from rules via the CLI or programmatically.
Suggestions are primarily chosen instead of fixers as:

  1. the code may be incomplete (e.g. no-unused-vars)
  2. the code may be temporary (e.g. no-console)
  3. the runtime behavior of the code may change

Automatically applying suggestions is primarily intended for the cases 1) and 2),
as the user can specifically say my current code is complete (especially useful for git commit hooks) and they know the potential risks.

What do you think is the correct solution?

A new option applySuggestions for the CLI and a new static method applySuggestions, similar to the existing outputFixes, on the ESLintclass.
These would be given a list of specifiers in the format {RULE_ID}:{SUGGESTION_MESSAGE_ID} of which suggestions to apply. The suggestion message id may be optional if the rule only provides a single suggestion, e.g. from no-console`.

Participation

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

Additional comments

This issue is only for checking whether there is any interest in this before writing a more in depth RFC.

@DMartens DMartens added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint labels Apr 4, 2024
@nzakas
Copy link
Member

nzakas commented Apr 5, 2024

Suggestions were designed to not be applied in the CLI and only be available to integrations. This is because suggestions might change the behavior of code, and when that is done by the CLI, it's really difficult to track down any issues that might be caused.

So short answer: no, we don't want to look into doing this on the CLI.

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 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
Projects
Archived in project
Development

No branches or pull requests

2 participants