Skip to content

chore(eslint-plugin): migrate to vitest #10579

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
merged 39 commits into from
Apr 14, 2025

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Dec 31, 2024

PR Checklist

Overview

this is just one possible PR for migrating to vitest

we need to avoid an unreviewable, giant PR, so the following has been done in this one:

  • only migrate eslint-plugin for now
  • for docs snapshots, retain a similar format rather than moving to the standard one-snapshot-per-file
  • for all other snapshots, just update the snapshot (since they only had one per file already)

Depends on #10582

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @43081j!

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 Dec 31, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 1ace444
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67fd6d226c3e8200088c1f61
😎 Deploy Preview https://deploy-preview-10579--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: 77 (🔴 down 19 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 site configuration.

Copy link

nx-cloud bot commented Dec 31, 2024

View your CI Pipeline Execution ↗ for commit 1ace444.

Command Status Duration Result
nx test eslint-plugin ✅ Succeeded 6m View ↗
nx test eslint-plugin-internal ✅ Succeeded 11s View ↗
nx test scope-manager ✅ Succeeded 18s View ↗
nx run types:build ✅ Succeeded 1s View ↗
nx test type-utils ✅ Succeeded 23s View ↗
nx typecheck ast-spec ✅ Succeeded 4s View ↗
nx run eslint-plugin:test -- --coverage ✅ Succeeded 6m 28s View ↗
nx run-many --target=build --exclude website --... ✅ Succeeded 1m 14s View ↗
Additional runs (26) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-04-14 20:33:29 UTC

@43081j 43081j mentioned this pull request Dec 31, 2024
14 tasks
@43081j 43081j changed the title chore(eslint-plugin) migrate to vitest chore(eslint-plugin): migrate to vitest Dec 31, 2024
@43081j 43081j force-pushed the eslint-plugin-vitest branch 4 times, most recently from a40aad9 to 4f4c6f1 Compare December 31, 2024 17:26
Migrates from jest to vitest.

The primary differences:

- You must import `describe`, `it`, etc
- Snapshots are not combined into one file by default
- ESM test files must be `.mts` (since we're in a `commonjs` package)
Tries to keep a similar format for sake of code review.

We can do a separate PR to drop this format and move to a snapshot per
file in future.
@43081j 43081j force-pushed the eslint-plugin-vitest branch from 4f4c6f1 to d69f679 Compare December 31, 2024 17:27
Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.82%. Comparing base (9531492) to head (1ace444).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10579      +/-   ##
==========================================
+ Coverage   84.31%   90.82%   +6.51%     
==========================================
  Files         497      497              
  Lines       27766    50192   +22426     
  Branches     5075     8267    +3192     
==========================================
+ Hits        23411    45588   +22177     
- Misses       4184     4589     +405     
+ Partials      171       15     -156     
Flag Coverage Δ
unittest 90.82% <ø> (+6.51%) ⬆️

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

see 207 files with indirect coverage changes

🚀 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.

@JoshuaKGoldberg
Copy link
Member

This is awesome, thanks for sending @43081j! I'd really like to dive in soon and see if we can get this merged. But we're a little swamped catching up on issues after the holiday & new year break, and this is a lot of changes. So it'll probably be a little while till we can take a deep look. 😬

In the meantime, some notes:

  • eslint-plugin is one of our biggest packages. Is there a reason you wanted to start with this, and not a smaller one like eslint-plugin-internal or type-utils?
  • Codecov is reporting a significant % drop, which means coverage is probably not set up right with it - could you take a look please?
  • Although we all would prefer to move away from implicit globals, adding in the import { describe, it, ... } from 'vitest' is adding a lot to the diff. Is there a reason not to enable Vitest globals for now - with a followup to remove it later?

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jan 13, 2025
@43081j
Copy link
Contributor Author

43081j commented Jan 13, 2025

eslint-plugin is one of our biggest packages. Is there a reason you wanted to start with this, and not a smaller one like eslint-plugin-internal or type-utils?

no particular reason, i just chose the package i was looking at at the time

Codecov is reporting a significant % drop, which means coverage is probably not set up right with it - could you take a look please?

ill have a look

Although we all would prefer to move away from implicit globals, adding in the import { describe, it, ... } from 'vitest' is adding a lot to the diff. Is there a reason not to enable Vitest globals for now - with a followup to remove it later?

we could use globals but i would say the diff is actually mostly from snapshot changes than it is from imports.

i think without the snapshot changes, it'd be a pretty small diff. so i'd prefer to keep them, but let me know if you don't

@43081j
Copy link
Contributor Author

43081j commented Jan 13, 2025

i manually compared the coverage locally and it seems to all be right. just vite reports more statements, and there's now a tools directory included which wasn't before

if you could have a look at some point too, that'd be helpful

@JoshuaKGoldberg
Copy link
Member

i think without the snapshot changes, it'd be a pretty small diff. so i'd prefer to keep them, but let me know if you don't

+1 from me on the small diff 😄. I'd prefer not to keep them. The smaller the diff the better!

if you could have a look at some point too, that'd be helpful

👍 ACK, we can help as part of the review if it's not figured out

@43081j
Copy link
Contributor Author

43081j commented Jan 13, 2025

+1 from me on the small diff 😄. I'd prefer not to keep them. The smaller the diff the better!

what i meant was that the imports don't add much to the diff, since the only reason this is a "big PR" is the snapshot changes rather than those imports.

i'd rather keep the imports seeing as its where we want to be

if you diff without snapshots, its small (but of course we need those snapshot updates in this PR)

as for the coverage change, im pretty sure it is just vite doing a much better job by using v8 coverage. that and the added tools/ directory seem to account for the difference

@ronami
Copy link
Member

ronami commented Jan 13, 2025

+1 from me on having the smallest diff.

Since this is already a large change, having it be gradual is a big plus. I think that moving from Vitest globals to using imports can be done separately on a future PR, which would help not miss anything on this PR.

@43081j
Copy link
Contributor Author

43081j commented Jan 13, 2025

i think we're getting lost a bit here

the imports don't contribute much at all to the diff. most of the diff is from snapshot updates, maybe its worth taking another look

im happy to use globals but i think we're picking at a minor thing that actually doesn't contribute much to the diff

@43081j
Copy link
Contributor Author

43081j commented Jan 18, 2025

i've now switched to using globals

we need to re-open #10582 and land #10680 before this

@43081j 43081j force-pushed the eslint-plugin-vitest branch from 2a0f201 to 265a448 Compare March 21, 2025 11:45
@43081j 43081j force-pushed the eslint-plugin-vitest branch from 265a448 to 84e24b3 Compare March 21, 2025 11:46
@43081j 43081j force-pushed the eslint-plugin-vitest branch from 4badf75 to e7c8adf Compare March 21, 2025 12:12
kirkwaiblinger
kirkwaiblinger previously approved these changes Mar 22, 2025
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.

Looks good to me!

@@ -403,6 +403,18 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
},
Copy link
Member

Choose a reason for hiding this comment

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

refer to #10978 (comment)

@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 Mar 28, 2025
@JoshuaKGoldberg
Copy link
Member

Starting to see this once in a while:

Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".

https://cloud.nx.app/runs/EisURTJuXm/task/eslint-plugin%3Atest

Something to keep an eye on...

@JoshuaKGoldberg JoshuaKGoldberg merged commit 1a3ab0d into typescript-eslint:main Apr 14, 2025
58 of 59 checks passed
@43081j 43081j deleted the eslint-plugin-vitest branch April 14, 2025 21:50
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

5 participants