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

[eslint] Enhance Rule.NodeListener type #45821

Conversation

acid-chicken
Copy link
Contributor

From #25399 (comment)

This change refines NodeListener type. It removes a necessity for useless type assertion inside of the function of RuleModule.create.

image

I'm newbie with DefinitelyTyped so I'm sorrry if the patch like this shouldn't be sent.

@typescript-bot typescript-bot added Where is GH Actions? GH Actions didn't give a response to this PR Popular package This PR affects a popular package (as counted by NPM download counts). Untested Change This PR does not touch tests labels Jul 1, 2020
@typescript-bot
Copy link
Contributor

typescript-bot commented Jul 1, 2020

@acid-chicken Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ❌ Most recent commit is approved by type definition owners or DT maintainers

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.

Inactive

This PR has been inactive for 31 days — it is considered abandoned!


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 45821,
  "author": "acid-chicken",
  "owners": [
    "pmdartus",
    "j-f1",
    "saadq",
    "JasonHK",
    "bradzacher"
  ],
  "dangerLevel": "ScopedAndTested",
  "headCommitAbbrOid": "3c01315",
  "headCommitOid": "3c013156a77c920950f9314448fd4352b561a1f0",
  "mergeIsRequested": false,
  "stalenessInDays": 31,
  "lastPushDate": "2020-08-22T04:23:52.000Z",
  "lastCommentDate": "2020-07-01T18:23:25.000Z",
  "maintainerBlessed": false,
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45821/files",
  "hasMergeConflict": false,
  "authorIsOwner": false,
  "isFirstContribution": true,
  "popularityLevel": "Popular",
  "newPackages": [],
  "packages": [
    "eslint"
  ],
  "files": [
    {
      "path": "types/eslint/eslint-tests.ts",
      "kind": "test",
      "package": "eslint"
    },
    {
      "path": "types/eslint/index.d.ts",
      "kind": "definition",
      "package": "eslint"
    }
  ],
  "hasDismissedReview": false,
  "ciResult": "pass",
  "reviewersWithStaleReviews": [
    {
      "reviewedAbbrOid": "0909c3e",
      "reviewer": "bradzacher",
      "date": "2020-08-03T15:49:42Z"
    },
    {
      "reviewedAbbrOid": "178e839",
      "reviewer": "bradzacher",
      "date": "2020-07-01T18:23:33Z"
    }
  ],
  "approvalFlags": 0,
  "isChangesRequested": false
}

@typescript-bot
Copy link
Contributor

typescript-bot commented Jul 1, 2020

🔔 @pmdartus @j-f1 @saadq @JasonHK @bradzacher — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@danger-public
Copy link

danger-public commented Jul 1, 2020

Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files.
The check for missing properties isn't always right, so take this list as advice, not a requirement.

eslint (unpkg)

was missing the following properties:

  1. linter

Generated by 🚫 dangerJS against 3c01315

@typescript-bot typescript-bot removed the Where is GH Actions? GH Actions didn't give a response to this PR label Jul 1, 2020
@typescript-bot typescript-bot moved this from Other to Waiting for Code Reviews in New Pull Request Status Board Jul 1, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in New Pull Request Status Board Jul 1, 2020
@typescript-bot typescript-bot removed the Untested Change This PR does not touch tests label Jul 1, 2020
@typescript-bot typescript-bot moved this from Needs Maintainer Review to Waiting for Code Reviews in New Pull Request Status Board Jul 1, 2020
@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #45821 diff
Batch compilation
Memory usage (MiB) 42.2 52.9 +25.4%
Type count 4569 11742 +157%
Assignability cache size 1109 1550 +40%
Language service
Samples taken 1716 1716 0%
Identifiers in tests 1716 1716 0%
getCompletionsAtPosition
    Mean duration (ms) 100.9 95.1 -5.8%
    Mean CV 11.7% 12.0%
    Worst duration (ms) 177.1 170.8 -3.6%
    Worst identifier desc getFirstTokensBetween
getQuickInfoAtPosition
    Mean duration (ms) 101.2 95.4 -5.7%
    Mean CV 12.1% 12.4% +2.7%
    Worst duration (ms) 186.5 164.9 -11.6%
    Worst identifier extensions getTokensBefore

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Jul 1, 2020
Comment on lines 239 to 245
type NodeListener = ESTree.Node extends infer T
? (T extends ESTree.Node ? (_: { [_ in T['type']]?: (node: T) => void }) => void : never) extends (
_: infer U,
) => void
? U
: never
: never;
Copy link
Contributor

@bradzacher bradzacher Jul 1, 2020

Choose a reason for hiding this comment

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

I don't think this kind of conditional logic is a good idea
In my experience, creating types dynamically like this over large sets (ESTree.Node is a union of 70 interfaces with 68 distinct type's) can easily cause OOMs in TS
microsoft/TypeScript#30473

This is evidenced by the above typescript-bot perf check which lists the memory usage as being 25% higher.

When I dumped this into a local repo, vscode's typescript integration paused for a few seconds whilst it computed the types.

The only thing that I've found to work efficiently is to list out every single key manually:
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/experimental-utils/src/ts-eslint/Rule.ts#L247-L424

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Jul 1, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Jul 1, 2020
@typescript-bot
Copy link
Contributor

@acid-chicken One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. If you disagree with the reviewer's comments, you can "dismiss" the review using GitHub's review UI. Thank you!

@typescript-bot
Copy link
Contributor

@acid-chicken I haven't seen any activity on this PR in more than 3 weeks, and this PR currently has problems that prevent it from being merged. The PR will be closed in a week if the issues aren't addressed.

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Aug 1, 2020
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Aug 1, 2020
@typescript-bot
Copy link
Contributor

@bradzacher Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Aug 1, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Aug 1, 2020
@typescript-bot
Copy link
Contributor

@acid-chicken The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Aug 1, 2020
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Aug 1, 2020
@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Aug 3, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in New Pull Request Status Board Aug 3, 2020
@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Aug 13, 2020
@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Needs Maintainer Action in New Pull Request Status Board Aug 13, 2020
@typescript-bot typescript-bot added Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. and removed Self Merge This PR can now be self-merged by the PR author or an owner Unmerged The author did not merge the PR when it was ready. labels Aug 22, 2020
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Needs Author Action in New Pull Request Status Board Aug 22, 2020
@typescript-bot
Copy link
Contributor

@acid-chicken Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day!

@typescript-bot typescript-bot removed Has Merge Conflict This PR can't be merged because it has a merge conflict. The author needs to update it. Owner Approved A listed owner of this package signed off on the pull request. labels Aug 22, 2020
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in New Pull Request Status Board Aug 22, 2020
@typescript-bot typescript-bot added the Abandoned This PR had no activity for a long time, and is considered abandoned label Sep 23, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in New Pull Request Status Board Sep 23, 2020
@sheetalkamat sheetalkamat merged commit e7b96c9 into DefinitelyTyped:master Sep 23, 2020
@typescript-bot typescript-bot removed this from Needs Maintainer Action in New Pull Request Status Board Sep 23, 2020
@typescript-bot
Copy link
Contributor

I just published @types/eslint@7.2.3 to npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Abandoned This PR had no activity for a long time, and is considered abandoned Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Popular package This PR affects a popular package (as counted by NPM download counts).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants