Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): add new extended ruleprefer-destructuring#7117
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
feat(eslint-plugin): add new extended ruleprefer-destructuring#7117
Uh oh!
There was an error while loading.Please reload this page.
Conversation
autofix is still wrong.
Thanks for the PR,@seiyab! 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 commentedJun 18, 2023 • 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 commentedJun 18, 2023 • 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.
prefer-destructuringUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
codecovbot commentedJun 20, 2023 • 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 Report
Additional details and impacted files@@ Coverage Diff @@## main #7117 +/- ##==========================================+ Coverage 85.25% 85.31% +0.06%========================================== Files 386 387 +1 Lines 13358 13417 +59 Branches 3943 3962 +19 ==========================================+ Hits 11388 11447 +59 Misses 1593 1593 Partials 377 377
Flags with carried forward coverage won't be shown.Click here to find out more.
|
JoshuaKGoldberg commentedAug 5, 2023
I also took the liberty of merging in from |
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
seiyab commentedAug 11, 2023
I have responded to your requests🚀 |
JoshuaKGoldberg 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.
LGTM, thanks for both sending & updating it (with so many tests)! 🔥
I'll defer to an additional review from @typescript-eslint/triage-team because this is the first instance I can find of callingbaseRule.create in two different potential ways.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
- naming of options- using nullish coalescing assignment
seiyab commentedAug 14, 2023 • 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.
Thank you for your review. |
seiyab commentedOct 5, 2023
@JoshuaKGoldberg |
JoshuaKGoldberg commentedOct 11, 2023 • 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.
Heh, I was hoping for an additional review, but it seems that everyone is slammed right now. Let's merge as-is 😄. Thanks for the ping! |
JoshuaKGoldberg 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.

Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
prefer-destructuring#1931Overview
Add a new base rule extension
@typescript-eslint/prefer-destructuringto resolve following issues.prefer-destructuring#1931#723 requests two things: 1. keep type annotation, 2. add an option to allow non-destructuring assignment for type annotated ones.
For the first one, I just disable auto fixer for declaration with type annotation, rather than providing correct auto fix. It's just because difficulty and maitainability.
For the second one, I add
enforceForDeclarationWithTypeAnnotationoption. I set default valuefalsebecause I agree with "annotations on destructured variables aren't very pretty" in the issue.#1931 requests type-aware version and I have implemented it for numeric index access for non-iterable object, that is the only case reported in the issue (excluding comments that are duplication of#723).
There is a notable thing for it. I treated numeric index access for non-iterable object as renamed one. So it is affected by
enforceForRenamedPropertiesoption.