#18008·eslint

Change Request: Rule Tester: Enforce that a rule marked `fixable` or `hasSuggestions` has a test case that produces a relevant fixer

Author: bradzacherCreated Jan 18, 2024Updated Sep 16, 2026
Labelsenhancementcoreneeds design

ESLint version

N/A

What problem do you want to solve?

Currently it's possible to declare a rule as both fixable and hasSuggestions without ever reporting either a fixer or a suggestion.

This is not great because often these flags are used for documentation purposes - which leads to bad documentation for users.

Additionally it's quite doable to create a suite of tests that never produces a fixer or a suggestion - this means that you can accidentally leave untested pathways in your rule. In the case of autofixers this is especially bad because you may not have validated that your code produces syntactically valid code!

What do you think is the correct solution?

It would be great if ESLint could do some post-run validation for a rule - for example:

  • "if the rule is marked as fixable and no tests produced a fixer - error"
  • "if the rule is marked as hasSuggestions and no tests produced suggestions - error"

One might suggest that this could be done via lint rules (eg eslint-plugin-eslint-plugin) - however it can be quite hard to statically analyse this given rules need not be contained within one file (so it's not possible to enforce the existence of a fixer on at least one context.report() call). Similarly tests may be assembled via generation in some way - meaning tests are dynamic and not possible to analyse. You might be able to catch some simpler cases with a lint rule.

Participation

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

Additional comments

No response