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): [no-extra-parens] keep parens around call expression arguments when type arguments contain parens #7375

Merged
merged 3 commits into from Aug 5, 2023

Conversation

auvred
Copy link
Member

@auvred auvred commented Jul 29, 2023

PR Checklist

Overview

This issue has a long story

After a little investigation I restored the chronology of changes:

  1. This PR introduced fix for this issue fix(eslint-plugin): [no-extra-parens] stop reporting on calling generic functions with one argument and type parameters containing parentheses #2319. Everything worked fine, and there was even a test case for such a situation
    https://github.com/typescript-eslint/typescript-eslint/pull/2319/files#diff-fbb45da7466e6a089a93155bac8bc3e3e16758e9ec33d941286852ed7d64f48bR31

  2. In this PR (feat: remove TSParenthesizedType #3340) the TSParenthesizedType was removed
    https://github.com/typescript-eslint/typescript-eslint/pull/3340/files#diff-a916a57c423a9435766d31cbea70b6434185d7f227eaff16df942efaab05b08bR86-R88
    The corresponding test case was also changed (I think this is a kind of regression)
    https://github.com/typescript-eslint/typescript-eslint/pull/3340/files#diff-fbb45da7466e6a089a93155bac8bc3e3e16758e9ec33d941286852ed7d64f48bR30-R32

  3. There was added check for TSArrayType fix(eslint-plugin): [no-extra-parens] handle generic ts array type. #5550. But as far as I understand it was just the edge case, because the same code without an array [] turns into a broken one


I couldn't find any other way to fix this problem other than checking if there any opening parenthesis between node.callee and first argument (node.arguments[0]). Otherwise eslint/no-extra-parens treats it as an opening parenthesis for the arguments list

Many thanks to this explanation #2314 (comment)

…ion arguments when type arguments contain parens
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @auvred!

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.

@netlify
Copy link

netlify bot commented Jul 29, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit f850fec
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/64cea6a1167c3500084a3a72
😎 Deploy Preview https://deploy-preview-7375--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 configuration.

@nx-cloud
Copy link

nx-cloud bot commented Jul 29, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f850fec. 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 35 targets

Sent with 💌 from NxCloud.

@codecov
Copy link

codecov bot commented Jul 29, 2023

Codecov Report

Merging #7375 (c273b85) into main (c869aa1) will increase coverage by 0.01%.
Report is 40 commits behind head on main.
The diff coverage is 64.70%.

❗ Current head c273b85 differs from pull request most recent head f850fec. Consider uploading reports for the commit f850fec to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7375      +/-   ##
==========================================
+ Coverage   87.40%   87.41%   +0.01%     
==========================================
  Files         381      381              
  Lines       13313    13316       +3     
  Branches     3934     3935       +1     
==========================================
+ Hits        11636    11640       +4     
- Misses       1292     1298       +6     
+ Partials      385      378       -7     
Flag Coverage Δ
unittest 87.41% <64.70%> (+0.01%) ⬆️

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

Files Changed Coverage Δ
...kages/scope-manager/src/referencer/ClassVisitor.ts 91.73% <ø> (ø)
packages/type-utils/src/predicates.ts 21.73% <0.00%> (ø)
...ipt-estree/src/parseSettings/warnAboutTSVersion.ts 93.33% <ø> (ø)
packages/typescript-estree/src/convert.ts 30.03% <31.25%> (ø)
...eslint-plugin/src/rules/type-annotation-spacing.ts 83.09% <50.00%> (+1.40%) ⬆️
...eslint-plugin/src/rules/consistent-type-imports.ts 94.50% <100.00%> (ø)
packages/eslint-plugin/src/rules/indent.ts 88.09% <100.00%> (ø)
packages/eslint-plugin/src/rules/key-spacing.ts 99.30% <100.00%> (ø)
...ackages/eslint-plugin/src/rules/no-extra-parens.ts 91.35% <100.00%> (ø)
...es/eslint-plugin/src/rules/no-floating-promises.ts 100.00% <100.00%> (ø)
... and 10 more

JoshuaKGoldberg
JoshuaKGoldberg previously approved these changes Aug 5, 2023
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

What a great PR description - thanks both for the fix and excellent writeup @auvred!

Ryan Gosling happily clapping

packages/eslint-plugin/src/rules/no-extra-parens.ts Outdated Show resolved Hide resolved
@JoshuaKGoldberg JoshuaKGoldberg merged commit 38e5e4e into typescript-eslint:main Aug 5, 2023
44 of 45 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants