`fixable` property only necessary when `meta` is present
See original GitHub issueWhat did you expect to happen?
Per the docs:
Important: Without the fixable property, ESLint does not apply fixes even if the rule implements fix functions. Omit the fixable property if the rule is not fixable.
Based on this, I would expect a rule without any meta
at all to also not be fixable.
What actually happened? Please include the actual, raw output from ESLint.
A rule without meta
is successfully fixed when it has a fixer.
The docs are true, however, if there is a meta
object of some sort (including an empty object); in such a case, an error will be reported that fixable
is necessary if the rule attempts to add a fixer. But if there is no meta
object at all, fixable
is not necessary for fixes to be applied for the rule.
I am not expecting breaking changes to start preventing fixers without meta
; I’d just expect the docs to mention that rules still without the recommended meta
property at all are currently still fixable.
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (20 by maintainers)
Because we don’t guarantee fixes to be applied, I think we can fix this behavior to work as it was originally intended. The result of using a rule with a legacy fixer is that it will only warn and not fix, which I wouldn’t consider a breaking change.
The bigger question is why
RuleTester
isn’t testing for this already. That’s one of our primary ways of enforcing rule standards and I’m surprised there’s not a check in there.Here’s what I would suggest as a path forward:
RuleTester
to check thatmeta.fixable
is present whenever a fix is provided. Release this first without changing how rules actually work.As clarified in today’s TSC meeting, steps 1-3 will apply to legacy (function) format as well.
Meaning that, as of
v8.0.0
, only rules that exportmeta.fixable
(which implies that it’s a new-format rule, and that it exportsmeta
) can be fixable. Inv8.0.0
, an error will be thrown during linting whenever a rule that doesn’t satisfy this condition produces a fix.