Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(eslint-plugin-internal): migrate fromjest tovitest#10771

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
06ce4ac
Install `vitest`
aryaemami59Feb 3, 2025
210ba5b
Rename `jest.config.js` to `vitest.config.mts`
aryaemami59Feb 3, 2025
35a0d1d
chore(eslint-plugin-internal): migrate to `vitest`
aryaemami59Feb 3, 2025
0375fa8
Remove `vitest/no-done-callback` as it is deprecated.
aryaemami59Mar 7, 2025
73057f5
Fix Vitest config
aryaemami59Mar 7, 2025
de5857b
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Mar 7, 2025
1c6819f
Update `vitest` to version 3.0.8
aryaemami59Mar 7, 2025
bd7d3f3
Fix Vitest config
aryaemami59Mar 7, 2025
e595cf8
Include `vitest.config.mts` in `tsconfig.spec.json`
aryaemami59Mar 7, 2025
8edaa18
Add `vitest.config.mts` files to ESLint configuration
aryaemami59Mar 8, 2025
c3efc9e
Type check `vitest.config.mts` files using project references.
aryaemami59Mar 8, 2025
21a6b84
Use `defineProject` instead of `defineConfig`
aryaemami59Mar 10, 2025
139c934
Simplify `workspace` and `coverage.exclude`
aryaemami59Mar 10, 2025
3156655
Explicitly enable `resolveJsonModule`
aryaemami59Mar 10, 2025
5191e9b
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Mar 10, 2025
1e2c8b2
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Mar 10, 2025
d0b822d
Use `.replace` instead of `.split`
aryaemami59Mar 10, 2025
82af72c
Fix `@nx/vite/plugin` usage in `nx.json`
aryaemami59Mar 10, 2025
9663ca2
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Mar 10, 2025
362cd3f
Update `@vitest/eslint-plugin` to version 1.1.37
aryaemami59Mar 11, 2025
c60c84f
Fix Vitest config
aryaemami59Mar 12, 2025
641440d
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Mar 12, 2025
0dc29d0
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Mar 15, 2025
ab86d18
Update `vite` to version 6.2.2
aryaemami59Mar 15, 2025
c607191
Fix `typecheck` task
aryaemami59Mar 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletioneslint.config.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import eslintCommentsPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs';
import tseslintInternalPlugin from '@typescript-eslint/eslint-plugin-internal';
import vitestPlugin from '@vitest/eslint-plugin';
import eslintPluginPlugin from 'eslint-plugin-eslint-plugin';
import importPlugin from 'eslint-plugin-import';
import jestPlugin from 'eslint-plugin-jest';
Expand All@@ -28,6 +29,10 @@ const restrictNamedDeclarations = {
selector: 'ExportNamedDeclaration[declaration=null][source=null]',
};

const vitestFiles = [
'packages/eslint-plugin-internal/tests/**/*.test.{ts,tsx,cts,mts}',
];

export default tseslint.config(
// register all of the plugins up-front
{
Expand All@@ -43,6 +48,7 @@ export default tseslint.config(
// @ts-expect-error -- https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/1038
['jsx-a11y']: jsxA11yPlugin.flatConfigs.recommended.plugins['jsx-a11y'],
['perfectionist']: perfectionistPlugin,
['vitest']: vitestPlugin,
// https://github.com/facebook/react/issues/28313
['react']: reactPlugin,
// @ts-expect-error -- Temporary types incompatibility pending flat config support
Expand DownExpand Up@@ -361,12 +367,22 @@ export default tseslint.config(
// define the jest globals for all test files
{
files: ['packages/*/tests/**/*.{ts,tsx,cts,mts}'],
ignores: vitestFiles,
languageOptions: {
globals: {
...jestPlugin.environments.globals.globals,
},
},
},
// define the vitest globals for all test files
{
files: vitestFiles,
languageOptions: {
globals: {
...vitestPlugin.environments.env.globals,
},
},
},
// test file specific configuration
{
files: [
Expand All@@ -376,6 +392,7 @@ export default tseslint.config(
'packages/integration-tests/tools/integration-test-base.ts',
'packages/integration-tests/tools/pack-packages.ts',
],
ignores: vitestFiles,
rules: {
'@typescript-eslint/no-empty-function': [
'error',
Expand All@@ -402,6 +419,34 @@ export default tseslint.config(
'jest/valid-expect': 'error',
},
},
// test file specific configuration
{
files: vitestFiles,
rules: {
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] },
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'vitest/no-alias-methods': 'error',
'vitest/no-disabled-tests': 'error',
'vitest/no-focused-tests': 'error',
'vitest/no-identical-title': 'error',
'vitest/no-test-prefixes': 'error',
'vitest/no-test-return-statement': 'error',
'vitest/prefer-each': 'error',
'vitest/prefer-spy-on': 'error',
'vitest/prefer-to-be': 'error',
'vitest/prefer-to-contain': 'error',
'vitest/prefer-to-have-length': 'error',
'vitest/valid-expect': 'error',
},
settings: { vitest: { typecheck: true } },
},
// plugin rule tests
{
files: [
Expand DownExpand Up@@ -430,7 +475,13 @@ export default tseslint.config(
},
},
{
files: ['eslint.config.{js,cjs,mjs}', 'knip.ts', 'packages/*/src/index.ts'],
files: [
'eslint.config.{js,cjs,mjs}',
'knip.ts',
'packages/*/src/index.ts',
'vitest.config.mts',
'packages/*/vitest.config.mts',
],
rules: {
// requirement
'import/no-default-export': 'off',
Expand Down
3 changes: 3 additions & 0 deletionsknip.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,9 @@ export default {
types: 'off',
unresolved: 'off',
},
vitest: {
config: ['vitest.config.mts', 'packages/*/vitest.config.mts'],
},
workspaces: {
'.': {
entry: ['tools/release/changelog-renderer.js', 'tools/scripts/**/*.mts'],
Expand Down
59 changes: 53 additions & 6 deletionsnx.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,28 @@
"configName": "tsconfig.build.json"
}
}
},
{
"plugin": "@nx/vite/plugin",
"include": ["packages/*"],
"options": {
"buildTargetName": "vite:build",
"testTargetName": "test",
"serveTargetName": "serve",
"devTargetName": "dev",
"previewTargetName": "preview",
"serveStaticTargetName": "serve-static",
"typecheckTargetName": "vite:typecheck",
"buildDepsTargetName": "vite:build-deps",
"watchDepsTargetName": "vite:watch-deps"
}
},
{
"plugin": "@nx/jest/plugin",
"include": ["packages/*"],
"options": {
"targetName": "test"
}
}
],
"release": {
Expand All@@ -40,19 +62,19 @@
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"],
"outputs": ["{projectRoot}/dist"],
"options": {
"cwd": "{projectRoot}"
},
"cache": true
},
"test": {
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.config.js",
"{workspaceRoot}/jest.config.base.js"
],
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/coverage"],
"cache": true
},
"@nx/jest:jest": {
"dependsOn": ["^build"],
"inputs": [
"default",
"^production",
Expand All@@ -72,7 +94,25 @@
}
}
},
"@nx/vite:test": {
"dependsOn": ["^build"],
"inputs": [
"default",
"^production",
"{workspaceRoot}/vitest.config.mts",
"{workspaceRoot}/vitest.config.base.mts",
"{projectRoot}/vitest.config.mts"
],
"outputs": ["{options.reportsDirectory}"],
"cache": true,
"options": {
"config": "{projectRoot}/vitest.config.mts",
"watch": false,
"reportsDirectory": "{projectRoot}/coverage"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"dependsOn": [
"eslint-plugin:build",
"eslint-plugin-internal:build",
Expand All@@ -87,6 +127,12 @@
"transitive": false
}
],
"outputs": ["{options.outputFile}"],
"cache": true
},
"typecheck": {
"dependsOn": ["types:copy-ast-spec"],
"outputs": ["{workspaceRoot}/dist/out-tsc/{projectRoot}"],
"cache": true
}
},
Expand All@@ -110,6 +156,7 @@
"!{projectRoot}/**/?(*.)+(test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/vitest.config.m[jt]s",
"!{projectRoot}/src/test-setup.[jt]s"
]
}
Expand Down
5 changes: 5 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,7 @@
"@nx/devkit": "20.4.5",
"@nx/eslint": "20.4.5",
"@nx/jest": "20.4.5",
"@nx/vite": "20.4.5",
"@nx/workspace": "20.4.5",
"@swc/core": "^1.4.12",
"@swc/jest": "^0.2.36",
Expand All@@ -88,6 +89,8 @@
"@typescript-eslint/types": "workspace:^",
"@typescript-eslint/typescript-estree": "workspace:^",
"@typescript-eslint/utils": "workspace:^",
"@vitest/coverage-v8": "^3.0.8",
"@vitest/eslint-plugin": "^1.1.37",
"console-fail-test": "^0.5.0",
"cross-fetch": "^4.0.0",
"cspell": "^8.15.2",
Expand DownExpand Up@@ -123,6 +126,8 @@
"tsx": "*",
"typescript": ">=4.8.4 <5.9.0",
"typescript-eslint": "workspace:^",
"vite": "^6.2.2",
"vitest": "^3.0.8",
"yargs": "17.7.2"
},
"resolutions": {
Expand Down
3 changes: 3 additions & 0 deletionspackages/ast-spec/project.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,9 @@
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"typecheck": {
"dependsOn": ["typescript-estree:build"]
}
}
}
8 changes: 0 additions & 8 deletionspackages/eslint-plugin-internal/jest.config.js
View file
Open in desktop

This file was deleted.

10 changes: 5 additions & 5 deletionspackages/eslint-plugin-internal/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,10 +16,10 @@
"scripts": {
"build": "npx tsc -b tsconfig.build.json",
"clean": "npx tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist && rimrafcoverage",
"postclean": "rimraf dist/coverage/",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"test": "jest",
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
"check-types": "npx nx typecheck"
},
"dependencies": {
Expand All@@ -31,8 +31,8 @@
"prettier": "^3.2.5"
},
"devDependencies": {
"@jest/types": "29.6.3",
"jest": "29.7.0",
"rimraf": "*"
"@vitest/coverage-v8": "^3.0.8",
"rimraf": "*",
"vitest": "^3.0.8"
}
}
8 changes: 6 additions & 2 deletionspackages/eslint-plugin-internal/project.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
{
"name": "eslint-plugin-internal",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"type": "library",
"implicitDependencies": [],
"projectType": "library",
"root": "packages/eslint-plugin-internal",
"sourceRoot": "packages/eslint-plugin-internal/src",
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/vite:test"
}
}
}
2 changes: 1 addition & 1 deletionpackages/eslint-plugin-internal/tsconfig.build.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@
"types": ["node"]
},
"include": ["src/**/*.ts", "index.d.ts"],
"exclude": ["jest.config.js", "src/**/*.spec.ts", "src/**/*.test.ts"],
"exclude": ["vitest.config.mts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"references": [
{
"path": "../type-utils/tsconfig.build.json"
Expand Down
9 changes: 7 additions & 2 deletionspackages/eslint-plugin-internal/tsconfig.spec.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,10 +3,12 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/eslint-plugin-internal",
"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",
Expand All@@ -16,6 +18,9 @@
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "../../tsconfig.spec.json"
}
]
}
21 changes: 21 additions & 0 deletionspackages/eslint-plugin-internal/vitest.config.mts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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.replace('@typescript-eslint/', ''),
root: import.meta.dirname,
},
}),
);

export default vitestConfig;
4 changes: 3 additions & 1 deletionproject.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,9 @@
"// These targets are used for repo level utils and checking repo files which do not belong to specific published packages": {},
"targets": {
"typecheck": {
"command": "tsc -b ./tsconfig.repo-config-files.json"
"command": "tsc -b ./tsconfig.repo-config-files.json",
"dependsOn": ["types:copy-ast-spec"],
"outputs": ["{workspaceRoot}/dist/out-tsc/root"]
},
"lint": {
"command": "eslint . --ignore-pattern=packages --cache"
Expand Down
9 changes: 8 additions & 1 deletiontsconfig.repo-config-files.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
"compilerOptions": {
"outDir": "dist/out-tsc/root/eslint",
"types": ["@types/node"],
"noEmit": true,
"allowJs": true,
"allowImportingTsExtensions": true
},
Expand All@@ -17,5 +16,13 @@
"jest.preset.js",
"knip.ts",
".github/**/*.js"
],
"references": [
{
"path": "./packages/typescript-eslint/tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp