Skip to content

fix(visitor-keys): fix visitor keys order #11279

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

Merged

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Jun 6, 2025

PR Checklist

Overview

As discussed in #11276, visitor keys are not in source code order for 5 types:

  • TSImportType
  • TSIndexedAccessType
  • TSMethodSignature
  • TSPropertySignature
  • TSTypePredicate

This PR fixes that by altering the order of keys in AdditionalKeys.

The changes to test snapshots are incidental details.

It appears that visitation happening in source code order is not covered by tests, but no lint rules are impacted by this change. If required, I would be happy to add tests, if someone can point me to where to put them.

FYI: Oxc's JS-side AST for TS files now aligns exactly with TS-ESLint parser's. The discrepancies in visitation order addressed in this PR were discovered during the work on alignment to get there. Our conformance testing ensures that visitor keys (after the changes in this PR) result in visitation in source code order for all AST types, for all Test262 and TypeScript test cases.

Except... ExportSpecifier where local and exported are visited in wrong order. However, TS-ESLint inherits that problem from eslint-visitor-keys. eslint/js#655 hopes to address that one upstream.

Anyway, my point is: I imagine it'd be preferable for TS-ESLint to have your own test coverage for visitation order. However, if you choose to believe me, I can tell you that the types changed in this PR + ExportSpecifier are the only places where there is a problem.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @overlookmotel!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Jun 6, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit b5f8186
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/6842c8fd2f2cab000894ae6e
😎 Deploy Preview https://deploy-preview-11279--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

nx-cloud bot commented Jun 6, 2025

View your CI Pipeline Execution ↗ for commit b5f8186.

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 5s View ↗
nx run-many -t typecheck ✅ Succeeded 1m 58s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 18s View ↗
nx run-many -t lint ✅ Succeeded 11s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 6s View ↗
nx run integration-tests:test ✅ Succeeded <1s View ↗
nx run generate-configs ✅ Succeeded 8s View ↗
nx run types:build ✅ Succeeded <1s View ↗
Additional runs (27) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-06-06 11:05:59 UTC

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.91%. Comparing base (0f5c59c) to head (b5f8186).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11279   +/-   ##
=======================================
  Coverage   90.91%   90.91%           
=======================================
  Files         501      501           
  Lines       50869    50869           
  Branches     8382     8382           
=======================================
  Hits        46248    46248           
  Misses       4606     4606           
  Partials       15       15           
Flag Coverage Δ
unittest 90.91% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/visitor-keys/src/visitor-keys.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Thanks for sending this!

RE the test coverage - I think let's get this merged and I'd invite you to file a followup issue for the test coverage question.

@kirkwaiblinger kirkwaiblinger added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jun 6, 2025
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

lgtm15.jpg

@bradzacher bradzacher merged commit 1e0ba62 into typescript-eslint:main Jun 7, 2025
77 checks passed
@overlookmotel overlookmotel deleted the fix-visitor-keys-order branch June 7, 2025 09:47
@overlookmotel
Copy link
Contributor Author

I'd invite you to file a followup issue for the test coverage question.

#11282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Visitor keys for 5 types are not in source order
3 participants