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(utils): migrate fromjest tovitest#10777

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
36 commits
Select commitHold shift + click to select a range
9cfcdb5
Install `vitest`
aryaemami59Feb 3, 2025
990b10c
Rename `jest.config.js` to `vitest.config.mts`
aryaemami59Feb 3, 2025
33e770f
chore(utils): migrate to `vitest`
aryaemami59Feb 4, 2025
5fe6661
Update `vitest` to version 3.0.8
aryaemami59Mar 7, 2025
ff4ea78
Fix Vitest config
aryaemami59Mar 7, 2025
aa690ea
Include `vitest.config.mts` in `tsconfig.spec.json`
aryaemami59Mar 8, 2025
e94d799
Add `vitest.config.mts` files to ESLint configuration
aryaemami59Mar 8, 2025
0bc3421
Use `defineProject` instead of `defineConfig`
aryaemami59Mar 10, 2025
f740b13
Explicitly enable `resolveJsonModule`
aryaemami59Mar 10, 2025
b88f326
Use `.replace` instead of `.split`
aryaemami59Mar 10, 2025
dbff826
Type check `vitest.config.mts` files using project references.
aryaemami59Mar 10, 2025
dd0a0ad
Update `@vitest/eslint-plugin` to version 1.1.37
aryaemami59Mar 11, 2025
5712fcf
Fix type tests
aryaemami59Mar 11, 2025
809e644
Fix Vitest config
aryaemami59Mar 12, 2025
d0bda83
Fix `typecheck` task
aryaemami59Mar 16, 2025
c07978f
Update `vitest` to version 3.0.9
aryaemami59Mar 26, 2025
b61cdb9
Update `@vitest/eslint-plugin` to version 1.1.38
aryaemami59Mar 26, 2025
2f4ac90
Include type-tests in ESLint config
aryaemami59Mar 27, 2025
8704850
Update `vitest` to version 3.1.1
aryaemami59Mar 31, 2025
8b4fc64
Update `@vitest/eslint-plugin` to version 1.1.39
aryaemami59Apr 2, 2025
1a2e35b
Switch to `test.for`
aryaemami59Apr 2, 2025
811cc57
Fix `knip` config
aryaemami59Apr 3, 2025
8f1a911
Update `vite` to version 6.2.5
aryaemami59Apr 3, 2025
d37cd19
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 7, 2025
32c8f53
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 7, 2025
5c0204c
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 10, 2025
9e24c92
Update `vite` to version 6.2.6
aryaemami59Apr 10, 2025
8b3dfb8
Update `@vitest/eslint-plugin` to version 1.1.40
aryaemami59Apr 10, 2025
ce8d947
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 10, 2025
f250393
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 11, 2025
911c77c
Update `@vitest/eslint-plugin` to version 1.1.42
aryaemami59Apr 11, 2025
978ac7a
Enable the new `vitest/prefer-describe-function-title` rule
aryaemami59Apr 11, 2025
a7db8f5
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 11, 2025
3f6d31a
Use `vitestPlugin.configs.env`
aryaemami59Apr 11, 2025
1492a81
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 11, 2025
005e0f2
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59Apr 11, 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
3 changes: 3 additions & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,3 +99,6 @@ packages/**/.yarn

.nx/cache
.nx/workspace-data

# Vitest type tests
tsconfig*.vitest-temp.json
1 change: 1 addition & 0 deletionseslint.config.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@ const vitestFiles = [
'packages/visitor-keys/tests/**/*.test.{ts,tsx,cts,mts}',
'packages/parser/tests/lib/**/*.test.{ts,tsx,cts,mts}',
'packages/parser/tests/test-utils/**/*.{ts,tsx,cts,mts}',
'packages/utils/tests/**/*.test?(-d).{ts,tsx,cts,mts}',
];

export default tseslint.config(
Expand Down
1 change: 0 additions & 1 deletionknip.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,7 +86,6 @@ export default {
},
'packages/utils': {
ignore: [
'tests/**/*.type-test.ts',
'typings/eslint.d.ts',
'typings/eslint-community-eslint-utils.d.ts',
],
Expand Down
7 changes: 0 additions & 7 deletionspackages/utils/jest.config.js
View file
Open in desktop

This file was deleted.

9 changes: 5 additions & 4 deletionspackages/utils/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,10 +57,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 _ts3.4 && rimraf_ts4.3 && rimrafcoverage",
"postclean": "rimraf dist/_ts4.3/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@@ -74,11 +74,12 @@
"typescript": ">=4.8.4 <5.9.0"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.1.1",
"downlevel-dts": "*",
"jest": "29.7.0",
"prettier": "^3.2.5",
"rimraf": "*",
"typescript": "*"
"typescript": "*",
"vitest": "^3.1.1"
},
"funding": {
"type": "opencollective",
Expand Down
9 changes: 7 additions & 2 deletionspackages/utils/project.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
{
"name": "utils",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"type": "library",
"implicitDependencies": [],
"projectType": "library",
"root": "packages/utils",
"sourceRoot": "packages/utils/src",
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/vite:test",
"dependsOn": ["^build", "typecheck"]
}
}
}
4 changes: 2 additions & 2 deletionspackages/utils/tests/eslint-utils/RuleCreator.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
import { ESLintUtils } from '../../src';

describe('RuleCreator', () => {
describe(ESLintUtils.RuleCreator, () => {
interface TestDocs {
recommended?: 'yes';
}

const createRule = ESLintUtils.RuleCreator<TestDocs>(name => `test/${name}`);

it('createRule should be a function', () => {
expect(typeofcreateRule).toBe('function');
expect(createRule).toBeTypeOf('function');
});

it('should create rule correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletionpackages/utils/tests/eslint-utils/applyDefault.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { ESLintUtils } from '../../src';

describe('applyDefault', () => {
describe(ESLintUtils.applyDefault, () => {
it('returns a clone of the default if no options given', () => {
const defaults = [{ prop: 'setting' }];
const user = null;
Expand Down
2 changes: 1 addition & 1 deletionpackages/utils/tests/eslint-utils/deepMerge.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { ESLintUtils } from '../../src';

describe('deepMerge', () => {
describe(ESLintUtils.deepMerge, () => {
it('creates a brand new object', () => {
const a = {};
const b = {};
Expand Down
19 changes: 9 additions & 10 deletionspackages/utils/tests/eslint-utils/getParserServices.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any -- wild and wacky testing */
import type * as ts from 'typescript';

import type { ParserServices, TSESLint, TSESTree } from '../../src';
Expand DownExpand Up@@ -38,14 +37,14 @@ const unknownParserErrorRegex = (parser?: string): RegExp =>
Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.`,
);

describe('getParserServices', () => {
describe(ESLintUtils.getParserServices, () => {
it('throws a standard error with the parser when parserOptions.esTreeNodeToTSNodeMap is missing and the parser is typescript-eslint', () => {
const context = createMockRuleContext({
sourceCode: {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
esTreeNodeToTSNodeMap: undefined as any,
esTreeNodeToTSNodeMap: undefined,
},
},
});
Expand All@@ -69,7 +68,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
esTreeNodeToTSNodeMap: undefined as any,
esTreeNodeToTSNodeMap: undefined,
},
},
});
Expand All@@ -87,7 +86,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
esTreeNodeToTSNodeMap: undefined as any,
esTreeNodeToTSNodeMap: undefined,
},
},
});
Expand All@@ -107,7 +106,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
esTreeNodeToTSNodeMap: undefined as any,
esTreeNodeToTSNodeMap: undefined,
},
},
});
Expand All@@ -124,7 +123,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
esTreeNodeToTSNodeMap: undefined as any,
esTreeNodeToTSNodeMap: undefined,
},
},
});
Expand All@@ -139,7 +138,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
tsNodeToESTreeNodeMap: undefined as any,
tsNodeToESTreeNodeMap: undefined,
},
},
});
Expand All@@ -155,7 +154,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
program: undefined as any,
program: undefined,
},
},
});
Expand All@@ -171,7 +170,7 @@ describe('getParserServices', () => {
...defaults.sourceCode,
parserServices: {
...defaults.sourceCode.parserServices,
program: undefined as any,
program: undefined,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletionpackages/utils/tests/eslint-utils/nullThrows.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { nullThrows, NullThrowsReasons } from '../../src/eslint-utils';

describe('nullThrows', () => {
describe(nullThrows, () => {
it('returns a falsy value when it exists', () => {
const value = 0;

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { parserSeemsToBeTSESLint } from '../../src/eslint-utils/parserSeemsToBeTSESLint';

describe('parserSeemsToBeTSESLint', () => {
test.each([
describe(parserSeemsToBeTSESLint, () => {
test.for([
[undefined, false],
['espree', false],
['local.js', false],
Expand All@@ -20,7 +20,7 @@ describe('parserSeemsToBeTSESLint', () => {
['/path/to/typescript-eslint/packages/parser/index.js', true],
['/path/to/@typescript-eslint/packages/parser/dist/index.js', true],
['/path/to/@typescript-eslint/packages/parser/index.js', true],
])('%s', (parserPath, expected) => {
] as const)('%s', ([parserPath, expected], { expect }) => {
expect(parserSeemsToBeTSESLint(parserPath)).toBe(expected);
});
});
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,8 +14,6 @@ type AllSelectors =
| `${TSESTree.AST_NODE_TYPES}:exit`
| `${TSESTree.AST_NODE_TYPES}`;

type ExpectNever<T extends never> = T;

type SelectorsWithWrongNodeType = {
[K in TSESTree.AST_NODE_TYPES]: Parameters<
NonNullable<RuleListener[K]>
Expand All@@ -25,13 +23,11 @@ type SelectorsWithWrongNodeType = {
: K
: K;
}[TSESTree.AST_NODE_TYPES];
type _test_rule_listener_selectors_have_correct_node_types =
ExpectNever<SelectorsWithWrongNodeType>;

type ExtraSelectors = Exclude<RuleListenerSelectors, AllSelectors>;
type _test_rule_listener_does_not_define_extra_selectors =
ExpectNever<ExtraSelectors>;
test('type tests', () => {
expectTypeOf<SelectorsWithWrongNodeType>().toBeNever();

expectTypeOf<RuleListenerSelectors>().exclude<AllSelectors>().toBeNever();

type MissingSelectors = Exclude<AllSelectors, RuleListenerSelectors>;
type _test_rule_listener_has_selectors_for_all_node_types =
ExpectNever<MissingSelectors>;
expectTypeOf<AllSelectors>().exclude<RuleListenerSelectors>().toBeNever();
});
2 changes: 1 addition & 1 deletionpackages/utils/tsconfig.build.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
},
"include": ["src/**/*.ts", "typings"],
"exclude": [
"jest.config.js",
"vitest.config.mts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"**/fixtures/**"
Expand Down
9 changes: 7 additions & 2 deletionspackages/utils/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/utils",
"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"
}
]
}
26 changes: 26 additions & 0 deletionspackages/utils/vitest.config.mts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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,

typecheck: {
enabled: true,
tsconfig: path.join(import.meta.dirname, 'tsconfig.spec.json'),
},
},
}),
);

export default vitestConfig;
3 changes: 2 additions & 1 deletionyarn.lock
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6312,11 +6312,12 @@ __metadata:
"@typescript-eslint/scope-manager": 8.29.1
"@typescript-eslint/types": 8.29.1
"@typescript-eslint/typescript-estree": 8.29.1
"@vitest/coverage-v8": ^3.1.1
downlevel-dts: "*"
jest: 29.7.0
prettier: ^3.2.5
rimraf: "*"
typescript: "*"
vitest: ^3.1.1
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: ">=4.8.4 <5.9.0"
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp