Navigation Menu

Skip to content
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

fix(eslint-plugin): [array-type] --fix flag removes parentheses from type #5997

Merged

Conversation

mhnaeem
Copy link
Contributor

@mhnaeem mhnaeem commented Nov 16, 2022

PR Checklist

Overview

Array type with intersection that has parentheses does not retain the parens. Remove an unnecessary check since the type node doesn't include parens.

Array type with intersection that has parentheses does not retain the parens.
typescript-eslint#5941
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @mhnaeem!

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 on https://opencollective.com/typescript-eslint.

@nx-cloud
Copy link

nx-cloud bot commented Nov 16, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2fe9b96. 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 46 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Nov 16, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 2fe9b96
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6374760ffd2f40000802d890
😎 Deploy Preview https://deploy-preview-5997--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 your Netlify site settings.

@codecov
Copy link

codecov bot commented Nov 16, 2022

Codecov Report

Merging #5997 (2fe9b96) into main (2778ff0) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5997   +/-   ##
=======================================
  Coverage   91.42%   91.42%           
=======================================
  Files         365      365           
  Lines       12339    12339           
  Branches     3609     3608    -1     
=======================================
  Hits        11281    11281           
  Misses        753      753           
  Partials      305      305           
Flag Coverage Δ
unittest 91.42% <100.00%> (ø)

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

Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/array-type.ts 97.14% <100.00%> (ø)

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Interesting—the fixer looks a bit hacky to me overall, but if there are no regressions, I like how simple the fix is.

Comment on lines +2010 to +2034
testOutput(
'array',
`
type WorkingArray = {
outerProperty: Array<
{ innerPropertyOne: string } & { innerPropertyTwo: string }
>;
}

type BrokenArray = {
outerProperty: Array<
({ innerPropertyOne: string } & { innerPropertyTwo: string })
>;
}
`,
`
type WorkingArray = {
outerProperty: ({ innerPropertyOne: string } & { innerPropertyTwo: string })[];
}

type BrokenArray = {
outerProperty: ({ innerPropertyOne: string } & { innerPropertyTwo: string })[];
}
`,
);
Copy link
Member

Choose a reason for hiding this comment

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

This test case looks identical to the one above?

Copy link
Contributor Author

@mhnaeem mhnaeem Nov 16, 2022

Choose a reason for hiding this comment

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

@Josh-Cena One is with type and the other one is with interface, I wanted to be sure it doesn't affect the code different on either keyword. I can modify it a bit if you like @Josh-Cena

Maybe something like
type BrokenArray = Array<({ a: number } & { b: string })>

@mhnaeem
Copy link
Contributor Author

mhnaeem commented Nov 16, 2022

Interesting—the fixer looks a bit hacky to me overall, but if there are no regressions, I like how simple the fix is.

@Josh-Cena I could not think of any regressions and the tests passed as well, if you have any other test cases you would like me to include I will be happy to.

@bradzacher bradzacher added the bug Something isn't working label Nov 16, 2022
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Thanks, it seems to work 👍

@Josh-Cena
Copy link
Member

For the record, the code was changed in #3340

@bradzacher bradzacher merged commit 5e2f852 into typescript-eslint:main Nov 23, 2022
@bradzacher bradzacher changed the title fix(eslint-plugin) [array-type] --fix flag removes parentheses from type fix(eslint-plugin): [array-type] --fix flag removes parentheses from type Nov 23, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [array-type] --fix removes neccesary brackets leading to a type with a different meaning
3 participants