diff --git a/eslint.config.mjs b/eslint.config.mjs index d95766112604..e4060e8d1dfd 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -31,6 +31,7 @@ const restrictNamedDeclarations = { const vitestFiles = [ 'packages/eslint-plugin-internal/tests/**/*.test.{ts,tsx,cts,mts}', + 'packages/typescript-eslint/tests/**/*.test.{ts,tsx,cts,mts}', ]; export default tseslint.config( diff --git a/packages/typescript-eslint/jest.config.js b/packages/typescript-eslint/jest.config.js deleted file mode 100644 index 88b83019e018..000000000000 --- a/packages/typescript-eslint/jest.config.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -// @ts-check -/** @type {import('@jest/types').Config.InitialOptions} */ -module.exports = { - ...require('../../jest.config.base.js'), - testRegex: './tests/.+\\.ts$', -}; diff --git a/packages/typescript-eslint/package.json b/packages/typescript-eslint/package.json index c9a13688057e..2ef7f7dce82d 100644 --- a/packages/typescript-eslint/package.json +++ b/packages/typescript-eslint/package.json @@ -46,10 +46,10 @@ "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts4.3/dist --to=4.3", "clean": "tsc -b tsconfig.build.json --clean", - "postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage", + "postclean": "rimraf dist/ _ts4.3/ coverage/", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "nx lint", - "test": "jest --passWithNoTests", + "test": "vitest --run --config=$INIT_CWD/vitest.config.mts", "check-types": "npx nx typecheck" }, "dependencies": { @@ -62,12 +62,12 @@ "typescript": ">=4.8.4 <5.9.0" }, "devDependencies": { - "@jest/types": "29.6.3", + "@vitest/coverage-v8": "^3.0.8", "downlevel-dts": "*", - "jest": "29.7.0", "prettier": "^3.2.5", "rimraf": "*", - "typescript": "*" + "typescript": "*", + "vitest": "^3.0.8" }, "funding": { "type": "opencollective", diff --git a/packages/typescript-eslint/project.json b/packages/typescript-eslint/project.json index f30e095e6523..121581ef2b13 100644 --- a/packages/typescript-eslint/project.json +++ b/packages/typescript-eslint/project.json @@ -1,12 +1,16 @@ { "name": "typescript-eslint", "$schema": "../../node_modules/nx/schemas/project-schema.json", - "type": "library", - "implicitDependencies": [], + "projectType": "library", + "root": "packages/typescript-eslint", + "sourceRoot": "packages/typescript-eslint/src", "targets": { "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] + }, + "test": { + "executor": "@nx/vite:test" } } } diff --git a/packages/typescript-eslint/tsconfig.build.json b/packages/typescript-eslint/tsconfig.build.json index 077800521627..ee18e9f1e1de 100644 --- a/packages/typescript-eslint/tsconfig.build.json +++ b/packages/typescript-eslint/tsconfig.build.json @@ -9,7 +9,7 @@ "types": ["node"] }, "include": ["src/**/*.ts"], - "exclude": ["jest.config.js", "src/**/*.spec.ts", "src/**/*.test.ts"], + "exclude": ["vitest.config.mts", "src/**/*.spec.ts", "src/**/*.test.ts"], "references": [ { "path": "../utils/tsconfig.build.json" diff --git a/packages/typescript-eslint/tsconfig.spec.json b/packages/typescript-eslint/tsconfig.spec.json index e1bbfca23474..e65e82d51bfa 100644 --- a/packages/typescript-eslint/tsconfig.spec.json +++ b/packages/typescript-eslint/tsconfig.spec.json @@ -3,10 +3,12 @@ "compilerOptions": { "outDir": "../../dist/out-tsc/packages/typescript-eslint", "module": "NodeNext", - "types": ["jest", "node"] + "resolveJsonModule": true, + "types": ["node", "vitest/globals", "vitest/importMeta"] }, "include": [ - "jest.config.js", + "vitest.config.mts", + "package.json", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts", @@ -16,6 +18,9 @@ "references": [ { "path": "./tsconfig.build.json" + }, + { + "path": "../../tsconfig.spec.json" } ] } diff --git a/packages/typescript-eslint/vitest.config.mts b/packages/typescript-eslint/vitest.config.mts new file mode 100644 index 000000000000..7d1cc31b83d7 --- /dev/null +++ b/packages/typescript-eslint/vitest.config.mts @@ -0,0 +1,21 @@ +import * as path from 'node:path'; +import { defineProject, mergeConfig } from 'vitest/config'; + +import { vitestBaseConfig } from '../../vitest.config.base.mjs'; +import packageJson from './package.json' with { type: 'json' }; + +const vitestConfig = mergeConfig( + vitestBaseConfig, + + defineProject({ + root: import.meta.dirname, + + test: { + dir: path.join(import.meta.dirname, 'tests'), + name: packageJson.name, + root: import.meta.dirname, + }, + }), +); + +export default vitestConfig; diff --git a/yarn.lock b/yarn.lock index 70aa80576f21..a7c2e8548c10 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20428,15 +20428,15 @@ __metadata: version: 0.0.0-use.local resolution: "typescript-eslint@workspace:packages/typescript-eslint" dependencies: - "@jest/types": 29.6.3 "@typescript-eslint/eslint-plugin": 8.27.0 "@typescript-eslint/parser": 8.27.0 "@typescript-eslint/utils": 8.27.0 + "@vitest/coverage-v8": ^3.0.8 downlevel-dts: "*" - jest: 29.7.0 prettier: ^3.2.5 rimraf: "*" typescript: "*" + vitest: ^3.0.8 peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0"