Skip to content

Commit 1a3ab0d

Browse files
43081jJoshuaKGoldbergkirkwaiblinger
authored
chore(eslint-plugin): migrate to vitest (#10579)
* chore(eslint-plugin): migrate to vitest 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) * chore(eslint-plugin): try retain a somewhat similar shot format 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. * chore(eslint-plugin): remove cross-spawn & add coverage-v8 * chore: add test-coverage script * test: add missing expect import * chore: use vitest globals for now * fix: single run vitest * chore: drop changes to it/test * chore(eslint-plugin): disallow jest types * chore(eslint-plugin): ignore jest linting * chore(typescript-eslint): drop passWithNoTests * chore(eslint-plugin): add console-fail-test * chore(eslint-plugin): revert test to it changes * test(eslint-plugin): use runIf instead of conditional block * chore: drop unused vitest setup * chore: fix test lint errors * chore: clean up tsconfigs * Fix introduced lint complaints * Update packages/eslint-plugin/package.json Co-authored-by: Kirk Waiblinger <[email protected]> * Update packages/eslint-plugin/package.json Co-authored-by: Kirk Waiblinger <[email protected]> * normalize eslint.config.mjs and fix lint reports * Remove unused devDependencies * dedupe vitest version * Updated test snapshot * Switch reporters to just github-actions * switch to basic reporter alongside github-actions * testTimeout: 10_000 --------- Co-authored-by: Josh Goldberg <[email protected]> Co-authored-by: Kirk Waiblinger <[email protected]>
1 parent 9531492 commit 1a3ab0d

File tree

268 files changed

+1905
-4796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+1905
-4796
lines changed

eslint.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const vitestFiles = [
3333
'packages/ast-spec/tests/**/*.test?(-d).{ts,tsx,cts,mts}',
3434
'packages/ast-spec/tests/util/setupVitest.mts',
3535
'packages/eslint-plugin-internal/tests/**/*.test.{ts,tsx,cts,mts}',
36+
'packages/eslint-plugin/tests/**/*.test.{ts,tsx,cts,mts}',
3637
'packages/integration-tests/tests/**/*.test.{ts,tsx,cts,mts},',
3738
'packages/integration-tests/tools/integration-test-base.ts',
3839
'packages/integration-tests/tools/pack-packages.ts',

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@
6969
"@nx/vite": "20.7.2",
7070
"@nx/workspace": "20.7.2",
7171
"@swc/core": "^1.4.12",
72-
"@swc/jest": "^0.2.36",
7372
"@types/babel__code-frame": "^7.0.6",
7473
"@types/babel__core": "^7.20.5",
7574
"@types/debug": "^4.1.12",
7675
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
7776
"@types/is-glob": "^4.0.4",
7877
"@types/jest": "29.5.13",
79-
"@types/jest-specific-snapshot": "^0.5.9",
8078
"@types/natural-compare": "^1.4.3",
8179
"@types/node": "^20.12.5",
8280
"@types/semver": "^7.5.8",

packages/eslint-plugin/jest.config.js

-14
This file was deleted.

packages/eslint-plugin/package.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"generate:breaking-changes": "tsx tools/generate-breaking-changes.mts",
5757
"generate:configs": "npx nx generate-configs repo",
5858
"lint": "npx nx lint",
59-
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --logHeapUsage",
60-
"test-single": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --no-coverage",
59+
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
60+
"test-single": "vitest --run --config=$INIT_CWD/vitest.config.mts",
6161
"check-types": "npx nx typecheck"
6262
},
6363
"dependencies": {
@@ -72,18 +72,15 @@
7272
"ts-api-utils": "^2.0.1"
7373
},
7474
"devDependencies": {
75-
"@jest/types": "29.6.3",
7675
"@types/marked": "^5.0.2",
7776
"@types/mdast": "^4.0.3",
7877
"@types/natural-compare": "*",
7978
"@typescript-eslint/rule-schema-to-typescript-types": "8.30.1",
8079
"@typescript-eslint/rule-tester": "8.30.1",
80+
"@vitest/coverage-v8": "^3.1.1",
8181
"ajv": "^6.12.6",
82-
"cross-env": "^7.0.3",
8382
"cross-fetch": "*",
8483
"eslint": "*",
85-
"jest": "29.7.0",
86-
"jest-specific-snapshot": "^8.0.0",
8784
"json-schema": "*",
8885
"markdown-table": "^3.0.3",
8986
"marked": "^5.1.2",
@@ -95,7 +92,8 @@
9592
"title-case": "^3.0.3",
9693
"tsx": "*",
9794
"typescript": "*",
98-
"unist-util-visit": "^5.0.0"
95+
"unist-util-visit": "^5.0.0",
96+
"vitest": "^3.1.1"
9997
},
10098
"peerDependencies": {
10199
"@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0",

packages/eslint-plugin/tests/docs-eslint-output-snapshots/adjacent-overload-signatures.shot

+2-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eslint-plugin/tests/docs-eslint-output-snapshots/array-type.shot

+6-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eslint-plugin/tests/docs-eslint-output-snapshots/await-thenable.shot

+11-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eslint-plugin/tests/docs-eslint-output-snapshots/ban-ts-comment.shot

+11-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)