question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`fixable` property only necessary when `meta` is present

See original GitHub issue

What 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:closed
  • Created 3 years ago
  • Comments:23 (20 by maintainers)

github_iconTop GitHub Comments

4reactions
nzakascommented, Jun 19, 2020

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:

  1. Make an announcement about this explaining that it is a bug and we know it will affect people.
  2. Update RuleTester to check that meta.fixable is present whenever a fix is provided. Release this first without changing how rules actually work.
  3. Fix the bug with how rule fixes are being applied in a subsequent release.
1reaction
mdjermanoviccommented, Jul 16, 2020

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 export meta.fixable (which implies that it’s a new-format rule, and that it exports meta) can be fixable. In v8.0.0, an error will be thrown during linting whenever a rule that doesn’t satisfy this condition produces a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<meta>: The metadata element - HTML - MDN Web Docs
The HTML element represents metadata that cannot be represented by other HTML meta-related elements, like , ,
Read more >
Element “meta” is missing one or more of the following attributes
Guide describing the HTML issue detected by the W3C Validator: Element “meta” is missing one or more of the following attributes: “itemprop”, “property”....
Read more >
TS1343: The 'import.meta' meta-property is only allowed when ...
I switched from jest to vitest , which got rid of this error. No changes to the test code were necessary. For reference,...
Read more >
Working with Rules - ESLint - Pluggable JavaScript Linter
In a custom rule or plugin, you can omit docs or include any properties that you need in it. fixable (string) is either...
Read more >
Open Graph Meta Tags: Everything You Need to Know - Ahrefs
<meta property="og:title" content="How to Become an SEO Expert (8 ... Only four are required for Facebook to understand the basics of your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found