Skip to content

fix(eslint-plugin): [no-unnecessary-type-parameters] clarify message #9737

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

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Aug 6, 2024

PR Checklist

Overview

Adds "in the (class|function) signature" to clarify the message. Also, shoutout @kirkwaiblinger, updated the rule's description and message to be clear that it reports when a type parameter isn't used multiple times. Using a type parameter 0 times or 1 time both cause a report.

💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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.

Copy link

netlify bot commented Aug 6, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 23f47d2
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66ba3e49ad1e3000084beb58
😎 Deploy Preview https://deploy-preview-9737--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 87 (🔴 down 8 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Aug 6, 2024

@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team August 6, 2024 17:03
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.94%. Comparing base (fc3ba92) to head (d65f50e).
Report is 1 commits behind head on main.

Current head d65f50e differs from pull request most recent head 23f47d2

Please upload reports for the commit 23f47d2 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9737      +/-   ##
==========================================
+ Coverage   87.90%   87.94%   +0.03%     
==========================================
  Files         403      402       -1     
  Lines       13765    13725      -40     
  Branches     4010     3997      -13     
==========================================
- Hits        12100    12070      -30     
+ Misses       1358     1350       -8     
+ Partials      307      305       -2     
Flag Coverage Δ
unittest 87.94% <100.00%> (+0.03%) ⬆️

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

Files Coverage Δ
...plugin/src/rules/no-unnecessary-type-parameters.ts 96.29% <100.00%> (+1.44%) ⬆️

... and 7 files with indirect coverage changes

kirkwaiblinger
kirkwaiblinger previously approved these changes Aug 6, 2024
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Looks good to me on the "in the signature" changes, with appropriate node type 👍


Do we want to consider the part of the issue too that complains about it saying "used once" when it's used zero times? I think that change should be pretty simple since I think we can just use the identifierCounts right above the context.report() call to differentiate between 0 and 1 usages (which is to say, identifierCounts === 1 or identifierCounts === 2). But no need to include this if you think it's inadvisable

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Aug 12, 2024
@JoshuaKGoldberg JoshuaKGoldberg removed the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Aug 12, 2024
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team August 12, 2024 16:32
kirkwaiblinger
kirkwaiblinger previously approved these changes Aug 12, 2024
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Yay!
happy Monday coffee

@JoshuaKGoldberg
Copy link
Member Author

I'll fix up the merge conflict & formatting issues locally. 🚀

@kirkwaiblinger kirkwaiblinger added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Aug 12, 2024
@JoshuaKGoldberg
Copy link
Member Author

Oh and fyi @danvk - we're hoping to get this in today, but if you have more changes you'd want, let me know! I'm on task to apply them.

@JoshuaKGoldberg JoshuaKGoldberg merged commit abe351d into typescript-eslint:main Aug 12, 2024
14 checks passed
@JoshuaKGoldberg
Copy link
Member Author

Merging real quick to get this in before the auto release. 😄

@JoshuaKGoldberg JoshuaKGoldberg deleted the no-unnecessary-type-parameter-signature-message branch August 12, 2024 17:02
@danvk
Copy link
Collaborator

danvk commented Aug 12, 2024

LGTM on the wording.

I'm confused why we care about zero times in the context of this rule, though. That would be an unused type parameter, and TypeScript already complains about those.

image

Copy link

Uh oh! @danvk, the image you shared is missing helpful alt text. Check #9737 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@JoshuaKGoldberg
Copy link
Member Author

Ah, that's a very good point. Agreed - the rule shouldn't handle that in the first place! I'm stepping away and can't file an issue at the moment, but should have time later this week if you haven't by then.

Between this, #9740, and #9741, I'm feeling good about solidifying this rule. 🙂

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [no-unnecessary-type-parameters] misleading error messages
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy