microsoft / microsoft/DefinitelyTyped-tools

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

Open
#734 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
423
Forks
237
Avg merge
18h 18m
Merged PRs (30d)
11

Description

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 https://github.com/microsoft/DefinitelyTyped-tools/blob/822dadbed4d2946f399400fd512599d0a2505d51/packages/eslint-plugin/src/rules/no-unnecessary-generics.ts#L57 it seems this is intentional.

Is this good? What do you think?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read packages/eslint-plugin/src/rules/no-unnecessary-generics.ts around line 57, then reproduce the TypeScript example from the issue to observe the current diagnostic location. Done means the rule reports the first mention of TElement rather than the JQuery return type, with behavior covered by the relevant rule tests if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.