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(eslint-plugin): [sort-type-constituents, sort-type-union-intersection-members] handle some required parentheses cases in the fixer#6118
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,@cherryblossom000! 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. |
nx-cloudbot commentedNov 28, 2022 • 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.
netlifybot commentedNov 28, 2022 • 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 settings. |
codecovbot commentedNov 28, 2022 • 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 #6118 +/- ##==========================================- Coverage 91.27% 91.26% -0.01%========================================== Files 366 366 Lines 12417 12416 -1 Branches 3631 3632 +1 ==========================================- Hits 11333 11332 -1 Misses 774 774 Partials 310 310
Flags with carried forward coverage won't be shown.Click here to find out more.
|
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.
Code looks great, thanks! Just requesting changes on deduplicating it a bit. ✨
packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| node:TSESTree.TSIntersectionType|TSESTree.TSUnionType, | ||
| ):void{ | ||
| constsourceOrder=node.types.map(type=>{ | ||
| constsourceOrder=node.types.map((type):Constituent=>{ |
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.
Nit: any particular reason to add the return type explicitly, here and in the other file?
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.
I wanted to make it clear what theConstituent was and where it came from. I ended up getting rid ofConstituent when I extractedrequiresParentheses into a utility function.
9caa9eb tod7f2588Comparecherryblossom000 commentedNov 28, 2022
The force push is because I rebased with main due to a merge conflict. |
cherryblossom000 commentedNov 28, 2022 • 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.
I also realised there’s another bug with this rule: typeT=(B|C)&A gets fixed to typeT=C|A&B This is because |
| or&
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.
I wonder if we want to leverage TS's utilities here for completeness?
https://github.com/microsoft/TypeScript/blob/1b75edcec60415dfa77be2e04aeafce0efa2222e/src/compiler/factory/parenthesizerRules.ts
We probably can't consume them directly (cos I don't think the util existed in old versions of TS) - but we could probably fork it? Maybe something to do in a separate PR?
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.

Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
requiresParenthesesnow returnstruefor union types starting with|and intersection types starting with&.