fix: position of reporting ESLint rule no-unnecessary-generics#794
Conversation
| context.report({ | ||
| data: { name }, | ||
| messageId: "sole", | ||
| node: parserServices.tsNodeToESTreeNodeMap.get(res.soleUse), |
There was a problem hiding this comment.
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.
Lemme have a looksee - just grabbing some dinner
There was a problem hiding this comment.
simplified - think this is what you were suggesting?
There was a problem hiding this comment.
Yes, even further than I was suggesting, even! (Which is not bad.)
There was a problem hiding this comment.
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.
...or even MessageId | undefined 🔪 🔪
There was a problem hiding this comment.
gosh you guys are brutal. Let me sharpen the knife
There was a problem hiding this comment.
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. |
jakebailey
left a comment
There was a problem hiding this comment.
This seems fine to me, but curious what others think.
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
(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-genericsrule. 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?