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
fixable
property only necessary when meta
is present
#13349
Comments
@brettz9 Can you fill out an issue template? It's not clear to me what the desired outcome of this issue is. Thanks! |
I've updated to include those two headings relevant to a doc bug. |
Thank you for clarifying. Agreed, and PRs to improve documentation are always welcome! |
agreed. but shouldn't it? IMO, the fixer shouldnt work or throw an error if meta is not present. thoughts? |
Re: it not mentioning As far as whether it should be a breaking change to require However, I have come across quite a number of plugins using the legacy format or not using |
Hey guys I am looking to contribute to ESLint. I would like to work on this issue however based on what I read, I am not sure if this requires just a documentation fix. Can anyone appropriately guide me to work on it. I have already set up ESLint on my machine. |
This is marked as accepted for a documentation update, though I do think this is unclear behavior. |
Hi. I'm interested in taking this one if no one minds. Seems a pretty straight forward documentation update. |
If metadata property is missing, `fixable` essentially gets defaulted to true. Described this behavior in the docs as well as added recommendations to include metadata/type properties
Is anyone working on this issue? If not, I would not mind working on it. |
@brettz9 do you happen to know of any examples that currently rely on this buggy behavior by providing fixers without including I see three options to resolve this:
Which path I prefer would depend on how much fixing the buggy behavior would break. |
Authors I've encountered have thankfully been open to updates, e.g., recently with SonarSource/eslint-plugin-sonarjs#161 . (In the cases where the lack of I am waiting on one PR, Turbo87/eslint-plugin-chai-expect#99 , to introduce the new rule format, so I know at least one plugins still using the old format, but in this case, the rules do not happen to be fixable. If you were only going to fix the case of requiring However, I would think no. 1 on your list is not an option for a major bump when the fixing occurs with the deprecated rule format since that format (which did not even allow While I haven't done any exhaustive study (e.g., of https://github.com/dustinspecker/awesome-eslint/ or those on npm), I would think therefore that with no. 1 excluded, no. 2 could be chosen over no. 3 as:
IMO, it would be nice to also require |
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 Here's what I would suggest as a path forward:
|
If there is consensus on these steps, I could start working on |
3 of the other 4 TSC members left a 👍 on @nzakas’s comment, and nobody’s objected, so I’d say you’re good to go. |
I think the documentation is still incorrect, even if there's
It sounds like ESLint will just not apply fixes, but it actually throws when this happens. This was an intended change (#6043), so perhaps we should update the docs to be more accurate about what will actually happen. If we want the same behavior in the case when rule that provides fixes doesn't have |
Per @nzakas in #13349 (comment)
While this is speaking of only warning, it seems to me from this indication of (no longer) fixing, that the idea is to start treating legacy format rules the same, i.e., that all your steps should apply to both the legacy format (functions) and to missing |
I interpreted this comment differently since it wasn't originally intended to disallow fixable legacy-format rules. I'm not sure whether we should now break legacy-format rules that are following the spec for that format (working-with-rules-deprecated). @nzakas can you clarify this? I think we all agree to disallow new-format rules that produce fixes but don't export |
As clarified in today's TSC meeting, steps 1-3 will apply to legacy (function) format as well. Meaning that, as of |
I think this isn't necessary, similar to how it seems unnecessary for new-format rules that don't export |
…gnore-default-values * upstream/master: (66 commits) Sponsors: Sync README with website Sponsors: Sync README with website Sponsors: Sync README with website Sponsors: Sync README with website Sponsors: Sync README with website Chore: remove leche (fixes eslint#13287) (eslint#13533) Sponsors: Sync README with website Sponsors: Sync README with website 7.6.0 Build: changelog update for 7.6.0 Update: require `meta` for fixable rules in RuleTester (refs eslint#13349) (eslint#13489) Docs: fix broken links in developer guide (eslint#13518) Fix: Do not output `undefined` as line and column when it's unavailable (eslint#13519) Sponsors: Sync README with website Sponsors: Sync README with website Fix: Update the chatroom link to go directly to help channel (eslint#13536) Sponsors: Sync README with website Update: Change no-duplicate-case to comparing tokens (fixes eslint#13485) (eslint#13494) Docs: add ECMAScript 2020 to README (eslint#13510) 7.5.0 ...
Added "breaking" label for the remaining step 3. |
* Breaking: require `meta` for fixable rules (fixes #13349) * Change error message
What did you expect to happen?
Per the docs:
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 thatfixable
is necessary if the rule attempts to add a fixer. But if there is nometa
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 recommendedmeta
property at all are currently still fixable.The text was updated successfully, but these errors were encountered: