Skip to content

test(visitor-keys): add test to guard redundant visitor keys#10650

Closed
antfu wants to merge 2 commits intotypescript-eslint:mainfrom
antfu:test/visitor-keys-redudent
Closed

test(visitor-keys): add test to guard redundant visitor keys#10650
antfu wants to merge 2 commits intotypescript-eslint:mainfrom
antfu:test/visitor-keys-redudent

Conversation

@antfu
Copy link
Copy Markdown
Contributor

@antfu antfu commented Jan 14, 2025

PR Checklist

Overview

From #10649 I found there are quite some redundant visitor keys that mostly might due to the updates in eslint-vistior-keys. In order to locate them, I write a simple test to guard them - not sure if you consider them valid testing. With the tests, in this PR, I also removed the keys that are considered redundant.

Feel free to close this PR if it's not desired

@typescript-eslint
Copy link
Copy Markdown
Contributor

Thanks for the PR, @antfu!

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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 14, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit a3ff943
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/678637cb52f1c900080fa60f
😎 Deploy Preview https://deploy-preview-10650--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: 74 (🔴 down 24 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (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 site configuration.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 14, 2025

View your CI Pipeline Execution ↗ for commit a3ff943.

Command Status Duration Result
nx run-many --target=build --exclude website --... ✅ Succeeded 1s View ↗
nx run-many --target=clean ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-14 10:21:44 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 14, 2025

View your CI Pipeline Execution ↗ for commit a3ff943.

Command Status Duration Result
nx run-many --target=clean ✅ Succeeded 12s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-14 10:10:08 UTC

Copy link
Copy Markdown
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.

the keys aren't redundant!
unionWith will preserve our ordering for the keys.
this is VERY important because the ordering defines the order in which the properties are visited. An incorrect order can cause incorrect rule behaviour or incorrect scope analysis because the code is not visited in source order.

// say this is what eslint-visitor-keys exports
const KEYS = { a: ['a'] };

unionWith({}) == KEYS
unionWith({ a: [] }) == KEYS
unionWith({ a: ['b'] }) == { a: ['b', 'a'] }
unionWith({ a: ['b', 'a', 'c'] }) == { a: ['b', 'a', 'c'] }

By removing the keys you will cause unionWith to append missing keys to the end of the array -- causing a broken visit order!
This is why the tests are failing.

@antfu antfu closed this Jan 14, 2025
@antfu
Copy link
Copy Markdown
Contributor Author

antfu commented Jan 14, 2025

I see. Thanks for pointing out!

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants