Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(utils): add defaultOptions to meta in rule#10339
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR,@LuisUrrutia! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedNov 16, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
nx-cloudbot commentedNov 16, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit0537ef6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 fromNxCloud. |
bradzacher left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
thanks for doing this!
a few comments but it's looking good so far!
| defaultOptions?:Options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
All properties need JSDoc!
| defaultOptions?:Options; | |
| /** | |
| *Specifiesdefaultoptionsfortherule.Ifpresent, anyuser-providedoptionsintheirconfigwillbemergedontopofthemrecursively. | |
| *Thismergingwillbeapplieddirectlyto`context.options`. | |
| *Ifyouwantbackwards-compatiblesupportforearlierESLintversion;consider usingthetop-level`defaultOptions`instead. | |
| * | |
| * @sinceESLint9.15.0 | |
| */ | |
| defaultOptions?:Options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Added, but@since can't be used withESLint word.
| defaultOptions, | ||
| meta, | ||
| name, | ||
| ...rule | ||
| }:Readonly< | ||
| RuleWithMetaAndName<Options,MessageIds,PluginDocs> | ||
| >):RuleModule<MessageIds,Options,PluginDocs>{ | ||
| returncreateRule<Options,MessageIds,PluginDocs>({ | ||
| defaultOptions, | ||
| meta:{ | ||
| ...meta, | ||
| defaultOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It's worth noting that adding this to this function will fix the bug with base rule extensions because our codebase uses theRuleCreator function -- but it might leave the broader ecosystem in a weird state.
This will cause all rules to have a differentcontext.options value when run under ESLint v9.15.0 -- which could cause breakages in the ecosystem.
For reference -- currently we do not modify thecontext.options value -- meaning it exactly mirrors the value that a user sets in their config file and we instead pass the "merged options" in via a second argument --create(context, mergedOptions).
So if you passmeta.defaultOptions automatically then the first part of this behaviour no longer holds true and insteadcontext.options will represent the "merged options".
For now we should leave this function as-is, and instead update our extension rule implementation to passdefaultOptions both in the top-level location (for our current rule logic) and in themeta.defaultOptions location (for ESLint base rule logic).
| exporttypeNamedCreateRuleMeta< | ||
| MessageIdsextendsstring, | ||
| Optionsextendsreadonlyunknown[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Adding this new generic in this location is a breaking change.
It changes the meaning of existing code and could introduce type errors.
Instead it must be added after all type parameters AND it must be given a default value of[]
codecovbot commentedNov 16, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #10339 +/- ##==========================================+ Coverage 86.63% 86.69% +0.06%========================================== Files 433 434 +1 Lines 15202 15227 +25 Branches 4439 4445 +6 ==========================================+ Hits 13170 13201 +31+ Misses 1675 1670 -5+ Partials 357 356 -1
Flags with carried forward coverage won't be shown.Click here to find out more.
|
LuisUrrutia commentedNov 16, 2024
@bradzacher I made the requested changes, but now I will add the |
bradzacher commentedNov 17, 2024 • edited by kirkwaiblinger
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by kirkwaiblinger
Uh oh!
There was an error while loading.Please reload this page.
Sorry about the commit spam. I just reverted some of the changes you made to limit them to exactly the rules touched ineslint/eslint#17656 |
bradzacher left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
thanks for doing this!
I have tested this against 9.15 and this looks good!
f5e23e2 intotypescript-eslint:mainUh oh!
There was an error while loading.Please reload this page.
* Setup GitHub Actions for Pull request and main branch* Fix regression caused by typescript-eslint in combination with eslint@9.15.0Details on:typescript-eslint/typescript-eslint#10339* Resolve linter issues after updating packages
pavelkornev commentedNov 18, 2024
When do you plan to release this fix? |
bradzacher commentedNov 18, 2024
Please see the issue linked in the OP |

Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
ESLint v9.15.0 introduces default options using the
meta.defaultOptionsproperty. This PR updates the rules to adddefaultOptionsproperty tometaobject, and retains the previousdefaultOptionsplacement to ensure backward compatibility.