-
Notifications
You must be signed in to change notification settings - Fork 216
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: position of reporting ESLint rule no-unnecessary-generics #794
fix: position of reporting ESLint rule no-unnecessary-generics #794
Conversation
@@ -54,7 +54,7 @@ const rule = createRule({ | |||
context.report({ | |||
data: { name }, | |||
messageId: "sole", | |||
node: parserServices.tsNodeToESTreeNodeMap.get(res.soleUse), |
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 think you should be able to drop soleUse
or simplify otherwise, actually; I think it's only returned for this particular case.
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.
Lemme have a looksee - just grabbing some dinner
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.
simplified - think this is what you were suggesting?
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.
Yes, even further than I was suggesting, even! (Which is not bad.)
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.
Let's go even further 🔪 no need for an interface with just the one property. type Result = "ok" | ...
!
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.
...or even MessageId | undefined
🔪 🔪
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.
gosh you guys are brutal. Let me sharpen the knife
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.
how's this?
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.
Looks great!
feat: 🔪
nice touch :)
I am personally all for this, though I am guessing it errored on the use just so that you could easily see where the single use was. But, I don't personally think that's too helpful as usually the fix is to remove the generic, thereby making the one use error anyway. |
Yeah I bet a good followup would be to add a suggestion for removing it. |
FWIW you should also write a changeset for this PR ( |
c9e1795
to
32479d8
Compare
Added the changeset - hope that's right? |
Seems correct to me. |
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.
This seems fine to me, but curious what others think.
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.
(in case this is helpful at all)
This PR addresses #734 and is a result of pairing with the ever kind and generous @JoshuaKGoldberg.
When working on the formatting of Definitely Typed, we happened upon some surprising behaviour around the
no-unnecessary-generics
rule. In the words of George Bernard Shaw: "I often quote myself. It adds spice to my conversation." Let me quote me now:This PR implements the suggested change; moving the position of the report to the type parameter position.
What do you think?