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

no-unnecessary-generics reporting in a less useful place than it could? #734

Open
johnnyreilly opened this issue Sep 15, 2023 · 1 comment

Comments

@johnnyreilly
Copy link
Contributor

Hi all!

I've been looking into this Definitely Typed pull request and picking through the issues with @JoshuaKGoldberg. We encountered an interesting case with the no-unnecessary-generics rule which we think could be better. Consider:

    <TElement extends HTMLElement = HTMLElement>(
      html: JQuery.htmlString,
      ownerDocument_attributes?: Document | JQuery.PlainObject,
      // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
    ): JQuery<TElement>;

You'll note that we have an eslint-disable-next-line just before the last line; the ReturnType of the method. Without this in place the red squigglies would be under:

JQuery<TElement>
       ~~~~~~~~

This isn't the useful place to have this report. Perhaps the better place would be the first mention of TElement, like so:

    <TElement extends HTMLElement = HTMLElement>(
     ~~~~~~~~

Looking at

node: parserServices.tsNodeToESTreeNodeMap.get(res.soleUse),
it seems this is intentional.

Is this good? What do you think?

@JoshuaKGoldberg
Copy link
Contributor

FWIW I'd lean towards reporting on the type parameter itself. This behavior confused & surprised me at first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants