Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Conversation

@cherryblossom000
Copy link
Contributor

@cherryblossom000cherryblossom000 commentedNov 28, 2022
edited
Loading

PR Checklist

Overview

requiresParentheses now returnstrue for union types starting with| and intersection types starting with&.

@typescript-eslint
Copy link
Contributor

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-cloud
Copy link

nx-cloudbot commentedNov 28, 2022
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit2cf2ca9. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 fromNxCloud.

@netlify
Copy link

netlifybot commentedNov 28, 2022
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit2cf2ca9
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/638541d3e7f6e00008238f48
😎 Deploy Previewhttps://deploy-preview-6118--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site settings.

@codecov
Copy link

codecovbot commentedNov 28, 2022
edited
Loading

Codecov Report

Merging#6118 (d7f2588) intomain (267da4e) willdecrease coverage by0.00%.
The diff coverage is100.00%.

❗ Current headd7f2588 differs from pull request most recent head2cf2ca9. Consider uploading reports for the commit2cf2ca9 to get more accurate results

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
FlagCoverage Δ
unittest91.26% <100.00%> (-0.01%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
.../eslint-plugin/src/rules/sort-type-constituents.ts90.38% <100.00%> (-0.36%)⬇️
.../src/rules/sort-type-union-intersection-members.ts90.38% <100.00%> (-0.36%)⬇️
packages/eslint-plugin/src/util/misc.ts97.01% <100.00%> (+0.13%)⬆️

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a 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. ✨

node:TSESTree.TSIntersectionType|TSESTree.TSUnionType,
):void{
constsourceOrder=node.types.map(type=>{
constsourceOrder=node.types.map((type):Constituent=>{

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?

Copy link
ContributorAuthor

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.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelNov 28, 2022
@cherryblossom000
Copy link
ContributorAuthor

The force push is because I rebased with main due to a merge conflict.

@cherryblossom000
Copy link
ContributorAuthor

cherryblossom000 commentedNov 28, 2022
edited
Loading

I also realised there’s another bug with this rule:

typeT=(B|C)&A

gets fixed to

typeT=C|A&B

This is because(B | C) & A gets incorrectly fixed toA & B | C, which is then fixed toC | A & B.

@cherryblossom000cherryblossom000 changed the titlefix(eslint-plugin): [sort-type-constituents] correctly fix constituents with leading| or&fix(eslint-plugin): [sort-type-constituents] add missing parentheses in fixNov 28, 2022
@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelNov 30, 2022
Copy link
Member

@bradzacherbradzacher left a 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?

cherryblossom000 reacted with eyes emoji
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the fix for both rules!

flextape

I'm going to land this as is so we can get the fix out ASAP.
If we want to strengthen the logic further we can follow up in a separate PR.

cherryblossom000 reacted with thumbs up emoji
@bradzacherbradzacher changed the titlefix(eslint-plugin): [sort-type-constituents] add missing parentheses in fixfix(eslint-plugin): [sort-type-constituents, sort-type-union-intersection-members] handle some required parentheses cases in the fixerDec 2, 2022
@bradzacherbradzacher merged commit5d49d5d intotypescript-eslint:mainDec 2, 2022
@cherryblossom000cherryblossom000 deleted the sort-constituents-fix-fix branchDecember 2, 2022 03:49
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsDec 10, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg requested changes

@bradzacherbradzacherbradzacher approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug: [sort-type-union-intersection-members] Fix for constituents with leading pipes or ampersands produces invalid output

3 participants

@cherryblossom000@JoshuaKGoldberg@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp