Skip to content

Commit 649309f

Browse files
authored
chore(typescript-eslint): migrate from jest to vitest (typescript-eslint#10772)
* Install `vitest` * Rename `jest.config.js` to `vitest.config.mts` * chore(typescript-eslint): migrate to `vitest` * Update `vitest` to version 3.0.8 * Remove `vitest/no-done-callback` as it is deprecated. * Fix Vitest config * Include `vitest.config.mts` in `tsconfig.spec.json` * Add `vitest.config.mts` files to ESLint configuration * Use `defineProject` instead of `defineConfig` * Simplify `workspace` and `coverage.exclude` * Explicitly enable `resolveJsonModule` * Type check `vitest.config.mts` files using project references. * Fix `@nx/vite/plugin` usage in `nx.json` * Update `@vitest/eslint-plugin` to version 1.1.37 * Fix Vitest config * Update `vite` to version 6.2.2 * Fix `typecheck` task
1 parent 8474474 commit 649309f

File tree

8 files changed

+43
-20
lines changed

8 files changed

+43
-20
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const restrictNamedDeclarations = {
3131

3232
const vitestFiles = [
3333
'packages/eslint-plugin-internal/tests/**/*.test.{ts,tsx,cts,mts}',
34+
'packages/typescript-eslint/tests/**/*.test.{ts,tsx,cts,mts}',
3435
];
3536

3637
export default tseslint.config(

packages/typescript-eslint/jest.config.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/typescript-eslint/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
"build": "tsc -b tsconfig.build.json",
4747
"postbuild": "downlevel-dts dist _ts4.3/dist --to=4.3",
4848
"clean": "tsc -b tsconfig.build.json --clean",
49-
"postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage",
49+
"postclean": "rimraf dist/ _ts4.3/ coverage/",
5050
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
5151
"lint": "nx lint",
52-
"test": "jest --passWithNoTests",
52+
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
5353
"check-types": "npx nx typecheck"
5454
},
5555
"dependencies": {
@@ -62,12 +62,12 @@
6262
"typescript": ">=4.8.4 <5.9.0"
6363
},
6464
"devDependencies": {
65-
"@jest/types": "29.6.3",
65+
"@vitest/coverage-v8": "^3.0.8",
6666
"downlevel-dts": "*",
67-
"jest": "29.7.0",
6867
"prettier": "^3.2.5",
6968
"rimraf": "*",
70-
"typescript": "*"
69+
"typescript": "*",
70+
"vitest": "^3.0.8"
7171
},
7272
"funding": {
7373
"type": "opencollective",
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"name": "typescript-eslint",
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4-
"type": "library",
5-
"implicitDependencies": [],
4+
"projectType": "library",
5+
"root": "packages/typescript-eslint",
6+
"sourceRoot": "packages/typescript-eslint/src",
67
"targets": {
78
"lint": {
89
"executor": "@nx/eslint:lint",
910
"outputs": ["{options.outputFile}"]
11+
},
12+
"test": {
13+
"executor": "@nx/vite:test"
1014
}
1115
}
1216
}

packages/typescript-eslint/tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"types": ["node"]
1010
},
1111
"include": ["src/**/*.ts"],
12-
"exclude": ["jest.config.js", "src/**/*.spec.ts", "src/**/*.test.ts"],
12+
"exclude": ["vitest.config.mts", "src/**/*.spec.ts", "src/**/*.test.ts"],
1313
"references": [
1414
{
1515
"path": "../utils/tsconfig.build.json"

packages/typescript-eslint/tsconfig.spec.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"compilerOptions": {
44
"outDir": "../../dist/out-tsc/packages/typescript-eslint",
55
"module": "NodeNext",
6-
"types": ["jest", "node"]
6+
"resolveJsonModule": true,
7+
"types": ["node", "vitest/globals", "vitest/importMeta"]
78
},
89
"include": [
9-
"jest.config.js",
10+
"vitest.config.mts",
11+
"package.json",
1012
"src/**/*.test.ts",
1113
"src/**/*.spec.ts",
1214
"src/**/*.d.ts",
@@ -16,6 +18,9 @@
1618
"references": [
1719
{
1820
"path": "./tsconfig.build.json"
21+
},
22+
{
23+
"path": "../../tsconfig.spec.json"
1924
}
2025
]
2126
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as path from 'node:path';
2+
import { defineProject, mergeConfig } from 'vitest/config';
3+
4+
import { vitestBaseConfig } from '../../vitest.config.base.mjs';
5+
import packageJson from './package.json' with { type: 'json' };
6+
7+
const vitestConfig = mergeConfig(
8+
vitestBaseConfig,
9+
10+
defineProject({
11+
root: import.meta.dirname,
12+
13+
test: {
14+
dir: path.join(import.meta.dirname, 'tests'),
15+
name: packageJson.name,
16+
root: import.meta.dirname,
17+
},
18+
}),
19+
);
20+
21+
export default vitestConfig;

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20428,15 +20428,15 @@ __metadata:
2042820428
version: 0.0.0-use.local
2042920429
resolution: "typescript-eslint@workspace:packages/typescript-eslint"
2043020430
dependencies:
20431-
"@jest/types": 29.6.3
2043220431
"@typescript-eslint/eslint-plugin": 8.27.0
2043320432
"@typescript-eslint/parser": 8.27.0
2043420433
"@typescript-eslint/utils": 8.27.0
20434+
"@vitest/coverage-v8": ^3.0.8
2043520435
downlevel-dts: "*"
20436-
jest: 29.7.0
2043720436
prettier: ^3.2.5
2043820437
rimraf: "*"
2043920438
typescript: "*"
20439+
vitest: ^3.0.8
2044020440
peerDependencies:
2044120441
eslint: ^8.57.0 || ^9.0.0
2044220442
typescript: ">=4.8.4 <5.9.0"

0 commit comments

Comments
 (0)