From 8f4c6cf1f93e8f7b04ae97bfbabcd76c32dc874e Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 5 May 2025 22:24:40 +0900 Subject: [PATCH 1/5] chore(*): init ESLint configurations to include 'vitest/expect-expect' rule as error across multiple packages gradually --- eslint.config.js | 5 +---- .../angular-query-experimental/eslint.config.js | 7 +++++++ .../src/__tests__/inject-query.test-d.ts | 7 +++++-- .../src/__tests__/mutation-options.test-d.ts | 7 +------ .../src/__tests__/query-options.test-d.ts | 15 +++++++-------- .../eslint.config.js | 9 ++++++++- .../eslint.config.js | 7 ++++++- packages/query-codemods/eslint.config.js | 1 + packages/query-core/eslint.config.js | 10 +++++++++- packages/query-core/src/__tests__/query.test.tsx | 2 +- .../query-persist-client-core/eslint.config.js | 9 ++++++++- .../query-sync-storage-persister/eslint.config.js | 9 ++++++++- packages/react-query-devtools/eslint.config.js | 1 + .../eslint.config.js | 1 + .../react-query-persist-client/eslint.config.js | 1 + packages/react-query/eslint.config.js | 1 + .../react-query/src/__tests__/useQuery.test-d.tsx | 7 +++++-- packages/solid-query-devtools/eslint.config.js | 9 ++++++++- .../solid-query-persist-client/eslint.config.js | 9 ++++++++- packages/solid-query/eslint.config.js | 7 ++++++- packages/svelte-query-devtools/eslint.config.js | 1 + .../svelte-query-persist-client/eslint.config.js | 1 + packages/svelte-query/eslint.config.js | 1 + packages/vue-query-devtools/eslint.config.js | 10 +++++++++- packages/vue-query/eslint.config.js | 10 +++++++++- .../vue-query/src/__tests__/useQuery.test-d.ts | 7 +++++-- 26 files changed, 119 insertions(+), 35 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index d8a54583771..f156cd2e9c2 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -45,10 +45,7 @@ export default [ { files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'], plugins: { vitest }, - rules: { - ...vitest.configs.recommended.rules, - 'vitest/expect-expect': 'warn', - }, + rules: vitest.configs.recommended.rules, settings: { vitest: { typecheck: true } }, }, ] diff --git a/packages/angular-query-experimental/eslint.config.js b/packages/angular-query-experimental/eslint.config.js index 84b0029c8e7..e161e6e17c0 100644 --- a/packages/angular-query-experimental/eslint.config.js +++ b/packages/angular-query-experimental/eslint.config.js @@ -1,13 +1,20 @@ // @ts-check import pluginJsdoc from 'eslint-plugin-jsdoc' +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, pluginJsdoc.configs['flat/recommended-typescript'], { + files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'], + plugins: { vitest }, rules: { + 'vitest/expect-expect': [ + 'error', + { assertFunctionNames: ['expect', 'expectSignals'] }, + ], 'cspell/spellchecker': [ 'warn', { diff --git a/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts b/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts index a49ca421cf2..406789dc424 100644 --- a/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts @@ -108,11 +108,14 @@ describe('initialData', () => { }) describe('structuralSharing', () => { - it('should restrict to same types', () => { + it('should be able to use structuralSharing with unknown types', () => { + // https://github.com/TanStack/query/issues/6525#issuecomment-1938411343 injectQuery(() => ({ queryKey: ['key'], queryFn: () => 5, - structuralSharing: (_oldData, newData) => { + structuralSharing: (oldData, newData) => { + expectTypeOf(oldData).toBeUnknown() + expectTypeOf(newData).toBeUnknown() return newData }, })) diff --git a/packages/angular-query-experimental/src/__tests__/mutation-options.test-d.ts b/packages/angular-query-experimental/src/__tests__/mutation-options.test-d.ts index 0aea5556a87..97f4b0d946f 100644 --- a/packages/angular-query-experimental/src/__tests__/mutation-options.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/mutation-options.test-d.ts @@ -2,12 +2,7 @@ import { mutationOptions } from '../mutation-options' describe('mutationOptions', () => { test('should not allow excess properties', () => { - return mutationOptions({ - mutationFn: () => Promise.resolve(5), - mutationKey: ['key'], - // @ts-expect-error this is a good error, because onMutates does not exist! - onMutates: 1000, - }) + expectTypeOf(mutationOptions).parameter(0).not.toHaveProperty('onMutates') }) test('should infer types for callbacks', () => { diff --git a/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts b/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts index 0d49180b4a1..18cd986adff 100644 --- a/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts @@ -4,16 +4,11 @@ import type { Signal } from '@angular/core' describe('queryOptions', () => { test('should not allow excess properties', () => { - return queryOptions({ - queryKey: ['key'], - queryFn: () => Promise.resolve(5), - // @ts-expect-error this is a good error, because stallTime does not exist! - stallTime: 1000, - }) + expectTypeOf(queryOptions).parameter(0).not.toHaveProperty('stallTime') }) test('should infer types for callbacks', () => { - return queryOptions({ + queryOptions({ queryKey: ['key'], queryFn: () => Promise.resolve(5), staleTime: 1000, @@ -24,7 +19,7 @@ describe('queryOptions', () => { }) test('should allow undefined response in initialData', () => { - return (id: string | null) => + const options = (id: string | null) => queryOptions({ queryKey: ['todo', id], queryFn: () => @@ -40,6 +35,10 @@ describe('queryOptions', () => { title: 'Initial Data', }, }) + + expectTypeOf(options(null).initialData).returns.toEqualTypeOf< + { id: string; title: string } | undefined + >() }) }) diff --git a/packages/query-async-storage-persister/eslint.config.js b/packages/query-async-storage-persister/eslint.config.js index df75435c7e1..b5ab9631f73 100644 --- a/packages/query-async-storage-persister/eslint.config.js +++ b/packages/query-async-storage-persister/eslint.config.js @@ -2,4 +2,11 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/query-broadcast-client-experimental/eslint.config.js b/packages/query-broadcast-client-experimental/eslint.config.js index df75435c7e1..30f96b18fa7 100644 --- a/packages/query-broadcast-client-experimental/eslint.config.js +++ b/packages/query-broadcast-client-experimental/eslint.config.js @@ -2,4 +2,9 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { 'vitest/expect-expect': 'warn' }, + }, +] diff --git a/packages/query-codemods/eslint.config.js b/packages/query-codemods/eslint.config.js index c3c009f41e8..569fdd58cf2 100644 --- a/packages/query-codemods/eslint.config.js +++ b/packages/query-codemods/eslint.config.js @@ -6,6 +6,7 @@ export default [ ...rootConfig, { rules: { + 'vitest/expect-expect': 'warn', 'cspell/spellchecker': 'off', '@typescript-eslint/no-unnecessary-condition': 'off', 'import/no-duplicates': 'off', diff --git a/packages/query-core/eslint.config.js b/packages/query-core/eslint.config.js index df75435c7e1..fdd52efb677 100644 --- a/packages/query-core/eslint.config.js +++ b/packages/query-core/eslint.config.js @@ -1,5 +1,13 @@ // @ts-check +import { rules } from '@cspell/eslint-plugin' import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/query-core/src/__tests__/query.test.tsx b/packages/query-core/src/__tests__/query.test.tsx index 03a0222b7fe..6d7485a6d7f 100644 --- a/packages/query-core/src/__tests__/query.test.tsx +++ b/packages/query-core/src/__tests__/query.test.tsx @@ -1003,7 +1003,7 @@ describe('query', () => { const key = queryKey() const queryFn = vi - .fn() + .fn<() => Promise>() .mockImplementation(() => sleep(10).then(() => 'data')) queryClient.prefetchQuery({ diff --git a/packages/query-persist-client-core/eslint.config.js b/packages/query-persist-client-core/eslint.config.js index df75435c7e1..b5ab9631f73 100644 --- a/packages/query-persist-client-core/eslint.config.js +++ b/packages/query-persist-client-core/eslint.config.js @@ -2,4 +2,11 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/query-sync-storage-persister/eslint.config.js b/packages/query-sync-storage-persister/eslint.config.js index df75435c7e1..b5ab9631f73 100644 --- a/packages/query-sync-storage-persister/eslint.config.js +++ b/packages/query-sync-storage-persister/eslint.config.js @@ -2,4 +2,11 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/react-query-devtools/eslint.config.js b/packages/react-query-devtools/eslint.config.js index ec7943f0190..0a918ec7093 100644 --- a/packages/react-query-devtools/eslint.config.js +++ b/packages/react-query-devtools/eslint.config.js @@ -15,6 +15,7 @@ export default [ 'react-hooks': pluginReactHooks, }, rules: { + 'vitest/expect-expect': 'warn', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', }, diff --git a/packages/react-query-next-experimental/eslint.config.js b/packages/react-query-next-experimental/eslint.config.js index 3554c211ee3..5c88107f957 100644 --- a/packages/react-query-next-experimental/eslint.config.js +++ b/packages/react-query-next-experimental/eslint.config.js @@ -15,6 +15,7 @@ export default [ 'react-hooks': pluginReactHooks, }, rules: { + 'vitest/expect-expect': 'warn', '@eslint-react/no-unstable-context-value': 'off', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', diff --git a/packages/react-query-persist-client/eslint.config.js b/packages/react-query-persist-client/eslint.config.js index ec7943f0190..0a918ec7093 100644 --- a/packages/react-query-persist-client/eslint.config.js +++ b/packages/react-query-persist-client/eslint.config.js @@ -15,6 +15,7 @@ export default [ 'react-hooks': pluginReactHooks, }, rules: { + 'vitest/expect-expect': 'warn', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', }, diff --git a/packages/react-query/eslint.config.js b/packages/react-query/eslint.config.js index aadb420b907..272d4809d4e 100644 --- a/packages/react-query/eslint.config.js +++ b/packages/react-query/eslint.config.js @@ -27,6 +27,7 @@ export default [ { files: ['**/__tests__/**'], rules: { + 'vitest/expect-expect': 'warn', '@typescript-eslint/no-unnecessary-condition': 'off', 'react-compiler/react-compiler': 'off', }, diff --git a/packages/react-query/src/__tests__/useQuery.test-d.tsx b/packages/react-query/src/__tests__/useQuery.test-d.tsx index c7feaf3c86a..5aa37fc3766 100644 --- a/packages/react-query/src/__tests__/useQuery.test-d.tsx +++ b/packages/react-query/src/__tests__/useQuery.test-d.tsx @@ -308,11 +308,14 @@ describe('useQuery', () => { }) describe('structuralSharing', () => { - it('should restrict to same types', () => { + it('should be able to use structuralSharing with unknown types', () => { + // https://github.com/TanStack/query/issues/6525#issuecomment-1938411343 useQuery({ queryKey: ['key'], queryFn: () => 5, - structuralSharing: (_oldData, newData) => { + structuralSharing: (oldData, newData) => { + expectTypeOf(oldData).toBeUnknown() + expectTypeOf(newData).toBeUnknown() return newData }, }) diff --git a/packages/solid-query-devtools/eslint.config.js b/packages/solid-query-devtools/eslint.config.js index df75435c7e1..b5ab9631f73 100644 --- a/packages/solid-query-devtools/eslint.config.js +++ b/packages/solid-query-devtools/eslint.config.js @@ -2,4 +2,11 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/solid-query-persist-client/eslint.config.js b/packages/solid-query-persist-client/eslint.config.js index df75435c7e1..b5ab9631f73 100644 --- a/packages/solid-query-persist-client/eslint.config.js +++ b/packages/solid-query-persist-client/eslint.config.js @@ -2,4 +2,11 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/solid-query/eslint.config.js b/packages/solid-query/eslint.config.js index df75435c7e1..8efcbb4d8df 100644 --- a/packages/solid-query/eslint.config.js +++ b/packages/solid-query/eslint.config.js @@ -2,4 +2,9 @@ import rootConfig from './root.eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + 'vitest/expect-expect': 'warn', + }, +] diff --git a/packages/svelte-query-devtools/eslint.config.js b/packages/svelte-query-devtools/eslint.config.js index f31c5e878b4..62bc0c16c31 100644 --- a/packages/svelte-query-devtools/eslint.config.js +++ b/packages/svelte-query-devtools/eslint.config.js @@ -8,6 +8,7 @@ export default [ ...pluginSvelte.configs['flat/recommended'], { rules: { + 'vitest/expect-expect': 'warn', 'svelte/block-lang': ['error', { script: ['ts'] }], 'svelte/no-svelte-internal': 'error', 'svelte/valid-compile': 'off', diff --git a/packages/svelte-query-persist-client/eslint.config.js b/packages/svelte-query-persist-client/eslint.config.js index f31c5e878b4..62bc0c16c31 100644 --- a/packages/svelte-query-persist-client/eslint.config.js +++ b/packages/svelte-query-persist-client/eslint.config.js @@ -8,6 +8,7 @@ export default [ ...pluginSvelte.configs['flat/recommended'], { rules: { + 'vitest/expect-expect': 'warn', 'svelte/block-lang': ['error', { script: ['ts'] }], 'svelte/no-svelte-internal': 'error', 'svelte/valid-compile': 'off', diff --git a/packages/svelte-query/eslint.config.js b/packages/svelte-query/eslint.config.js index f31c5e878b4..62bc0c16c31 100644 --- a/packages/svelte-query/eslint.config.js +++ b/packages/svelte-query/eslint.config.js @@ -8,6 +8,7 @@ export default [ ...pluginSvelte.configs['flat/recommended'], { rules: { + 'vitest/expect-expect': 'warn', 'svelte/block-lang': ['error', { script: ['ts'] }], 'svelte/no-svelte-internal': 'error', 'svelte/valid-compile': 'off', diff --git a/packages/vue-query-devtools/eslint.config.js b/packages/vue-query-devtools/eslint.config.js index 6cd1d47ba72..273b4778a99 100644 --- a/packages/vue-query-devtools/eslint.config.js +++ b/packages/vue-query-devtools/eslint.config.js @@ -4,4 +4,12 @@ import pluginVue from 'eslint-plugin-vue' import rootConfig from './root.eslint.config.js' -export default [...rootConfig, ...pluginVue.configs['flat/base']] +export default [ + ...rootConfig, + ...pluginVue.configs['flat/base'], + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/vue-query/eslint.config.js b/packages/vue-query/eslint.config.js index 6cd1d47ba72..273b4778a99 100644 --- a/packages/vue-query/eslint.config.js +++ b/packages/vue-query/eslint.config.js @@ -4,4 +4,12 @@ import pluginVue from 'eslint-plugin-vue' import rootConfig from './root.eslint.config.js' -export default [...rootConfig, ...pluginVue.configs['flat/base']] +export default [ + ...rootConfig, + ...pluginVue.configs['flat/base'], + { + rules: { + 'vitest/expect-expect': 'warn', + }, + }, +] diff --git a/packages/vue-query/src/__tests__/useQuery.test-d.ts b/packages/vue-query/src/__tests__/useQuery.test-d.ts index 3185a88957b..84437f8fc19 100644 --- a/packages/vue-query/src/__tests__/useQuery.test-d.ts +++ b/packages/vue-query/src/__tests__/useQuery.test-d.ts @@ -161,11 +161,14 @@ describe('useQuery', () => { }) describe('structuralSharing', () => { - it('should restrict to same types', () => { + it('should be able to use structuralSharing with unknown types', () => { + // https://github.com/TanStack/query/issues/6525#issuecomment-1938411343 useQuery({ queryKey: ['key'], queryFn: () => 5, - structuralSharing: (_oldData, newData) => { + structuralSharing: (oldData, newData) => { + expectTypeOf(oldData).toBeUnknown() + expectTypeOf(newData).toBeUnknown() return newData }, }) From 6dade4ed078da50ff4bdce04706754be3daf948f Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 5 May 2025 22:32:35 +0900 Subject: [PATCH 2/5] chore(query-core): remove unused import from ESLint configuration --- packages/query-core/eslint.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/query-core/eslint.config.js b/packages/query-core/eslint.config.js index fdd52efb677..b5ab9631f73 100644 --- a/packages/query-core/eslint.config.js +++ b/packages/query-core/eslint.config.js @@ -1,6 +1,5 @@ // @ts-check -import { rules } from '@cspell/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ From 8672a4d1dc0f622ee9df3848df40f1a27864e6ec Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 5 May 2025 22:35:52 +0900 Subject: [PATCH 3/5] chore(angular-query-experimental): update eslint rule --- .../angular-query-experimental/eslint.config.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/angular-query-experimental/eslint.config.js b/packages/angular-query-experimental/eslint.config.js index e161e6e17c0..e2112989492 100644 --- a/packages/angular-query-experimental/eslint.config.js +++ b/packages/angular-query-experimental/eslint.config.js @@ -8,13 +8,7 @@ export default [ ...rootConfig, pluginJsdoc.configs['flat/recommended-typescript'], { - files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'], - plugins: { vitest }, rules: { - 'vitest/expect-expect': [ - 'error', - { assertFunctionNames: ['expect', 'expectSignals'] }, - ], 'cspell/spellchecker': [ 'warn', { @@ -35,4 +29,14 @@ export default [ ], }, }, + { + files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'], + plugins: { vitest }, + rules: { + 'vitest/expect-expect': [ + 'error', + { assertFunctionNames: ['expect', 'expectSignals'] }, + ], + }, + }, ] From f9a5e53c925b00385e329534a99c8fd24b51e6e5 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 5 May 2025 22:46:10 +0900 Subject: [PATCH 4/5] chore: integrate vitest ESLint plugin and apply recommended rules across multiple packages --- packages/angular-query-experimental/eslint.config.js | 1 - packages/eslint-plugin-query/eslint.config.js | 1 + packages/query-async-storage-persister/eslint.config.js | 3 +++ .../query-broadcast-client-experimental/eslint.config.js | 7 ++++++- packages/query-codemods/eslint.config.js | 9 ++++++++- packages/query-core/eslint.config.js | 3 +++ packages/query-persist-client-core/eslint.config.js | 3 +++ packages/query-sync-storage-persister/eslint.config.js | 3 +++ packages/react-query-devtools/eslint.config.js | 8 +++++++- packages/react-query-next-experimental/eslint.config.js | 9 ++++++++- packages/react-query-persist-client/eslint.config.js | 9 ++++++++- packages/react-query/eslint.config.js | 9 ++++++++- packages/solid-query-devtools/eslint.config.js | 3 +++ packages/solid-query-persist-client/eslint.config.js | 3 +++ packages/solid-query/eslint.config.js | 7 ++++++- packages/svelte-query-devtools/eslint.config.js | 9 ++++++++- packages/svelte-query-persist-client/eslint.config.js | 9 ++++++++- packages/svelte-query/eslint.config.js | 9 ++++++++- packages/vue-query-devtools/eslint.config.js | 3 +++ packages/vue-query/eslint.config.js | 3 +++ 20 files changed, 100 insertions(+), 11 deletions(-) diff --git a/packages/angular-query-experimental/eslint.config.js b/packages/angular-query-experimental/eslint.config.js index e2112989492..a86775ff270 100644 --- a/packages/angular-query-experimental/eslint.config.js +++ b/packages/angular-query-experimental/eslint.config.js @@ -30,7 +30,6 @@ export default [ }, }, { - files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'], plugins: { vitest }, rules: { 'vitest/expect-expect': [ diff --git a/packages/eslint-plugin-query/eslint.config.js b/packages/eslint-plugin-query/eslint.config.js index cb04452c999..b6464bd8c98 100644 --- a/packages/eslint-plugin-query/eslint.config.js +++ b/packages/eslint-plugin-query/eslint.config.js @@ -8,6 +8,7 @@ export default [ { plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': [ 'warn', { diff --git a/packages/query-async-storage-persister/eslint.config.js b/packages/query-async-storage-persister/eslint.config.js index b5ab9631f73..7ccaf501775 100644 --- a/packages/query-async-storage-persister/eslint.config.js +++ b/packages/query-async-storage-persister/eslint.config.js @@ -1,11 +1,14 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/query-broadcast-client-experimental/eslint.config.js b/packages/query-broadcast-client-experimental/eslint.config.js index 30f96b18fa7..7ccaf501775 100644 --- a/packages/query-broadcast-client-experimental/eslint.config.js +++ b/packages/query-broadcast-client-experimental/eslint.config.js @@ -1,10 +1,15 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { - rules: { 'vitest/expect-expect': 'warn' }, + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, }, ] diff --git a/packages/query-codemods/eslint.config.js b/packages/query-codemods/eslint.config.js index 569fdd58cf2..c48269cff12 100644 --- a/packages/query-codemods/eslint.config.js +++ b/packages/query-codemods/eslint.config.js @@ -1,12 +1,12 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { rules: { - 'vitest/expect-expect': 'warn', 'cspell/spellchecker': 'off', '@typescript-eslint/no-unnecessary-condition': 'off', 'import/no-duplicates': 'off', @@ -16,4 +16,11 @@ export default [ 'sort-imports': 'off', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/query-core/eslint.config.js b/packages/query-core/eslint.config.js index b5ab9631f73..7ccaf501775 100644 --- a/packages/query-core/eslint.config.js +++ b/packages/query-core/eslint.config.js @@ -1,11 +1,14 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/query-persist-client-core/eslint.config.js b/packages/query-persist-client-core/eslint.config.js index b5ab9631f73..7ccaf501775 100644 --- a/packages/query-persist-client-core/eslint.config.js +++ b/packages/query-persist-client-core/eslint.config.js @@ -1,11 +1,14 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/query-sync-storage-persister/eslint.config.js b/packages/query-sync-storage-persister/eslint.config.js index b5ab9631f73..7ccaf501775 100644 --- a/packages/query-sync-storage-persister/eslint.config.js +++ b/packages/query-sync-storage-persister/eslint.config.js @@ -1,11 +1,14 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/react-query-devtools/eslint.config.js b/packages/react-query-devtools/eslint.config.js index 0a918ec7093..7881794de72 100644 --- a/packages/react-query-devtools/eslint.config.js +++ b/packages/react-query-devtools/eslint.config.js @@ -15,9 +15,15 @@ export default [ 'react-hooks': pluginReactHooks, }, rules: { - 'vitest/expect-expect': 'warn', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/react-query-next-experimental/eslint.config.js b/packages/react-query-next-experimental/eslint.config.js index 5c88107f957..45811bb8a14 100644 --- a/packages/react-query-next-experimental/eslint.config.js +++ b/packages/react-query-next-experimental/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginReact from '@eslint-react/eslint-plugin' import pluginReactHooks from 'eslint-plugin-react-hooks' import rootConfig from './root.eslint.config.js' @@ -15,10 +16,16 @@ export default [ 'react-hooks': pluginReactHooks, }, rules: { - 'vitest/expect-expect': 'warn', '@eslint-react/no-unstable-context-value': 'off', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/react-query-persist-client/eslint.config.js b/packages/react-query-persist-client/eslint.config.js index 0a918ec7093..9133d598946 100644 --- a/packages/react-query-persist-client/eslint.config.js +++ b/packages/react-query-persist-client/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginReact from '@eslint-react/eslint-plugin' import pluginReactHooks from 'eslint-plugin-react-hooks' import rootConfig from './root.eslint.config.js' @@ -15,9 +16,15 @@ export default [ 'react-hooks': pluginReactHooks, }, rules: { - 'vitest/expect-expect': 'warn', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/react-query/eslint.config.js b/packages/react-query/eslint.config.js index 272d4809d4e..60faf155e0e 100644 --- a/packages/react-query/eslint.config.js +++ b/packages/react-query/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginReact from '@eslint-react/eslint-plugin' // @ts-expect-error import pluginReactCompiler from 'eslint-plugin-react-compiler' @@ -27,9 +28,15 @@ export default [ { files: ['**/__tests__/**'], rules: { - 'vitest/expect-expect': 'warn', '@typescript-eslint/no-unnecessary-condition': 'off', 'react-compiler/react-compiler': 'off', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/solid-query-devtools/eslint.config.js b/packages/solid-query-devtools/eslint.config.js index b5ab9631f73..7ccaf501775 100644 --- a/packages/solid-query-devtools/eslint.config.js +++ b/packages/solid-query-devtools/eslint.config.js @@ -1,11 +1,14 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/solid-query-persist-client/eslint.config.js b/packages/solid-query-persist-client/eslint.config.js index b5ab9631f73..7ccaf501775 100644 --- a/packages/solid-query-persist-client/eslint.config.js +++ b/packages/solid-query-persist-client/eslint.config.js @@ -1,11 +1,14 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/solid-query/eslint.config.js b/packages/solid-query/eslint.config.js index 8efcbb4d8df..7ccaf501775 100644 --- a/packages/solid-query/eslint.config.js +++ b/packages/solid-query/eslint.config.js @@ -1,10 +1,15 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import rootConfig from './root.eslint.config.js' export default [ ...rootConfig, { - 'vitest/expect-expect': 'warn', + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, }, ] diff --git a/packages/svelte-query-devtools/eslint.config.js b/packages/svelte-query-devtools/eslint.config.js index 62bc0c16c31..b40d00982ab 100644 --- a/packages/svelte-query-devtools/eslint.config.js +++ b/packages/svelte-query-devtools/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginSvelte from 'eslint-plugin-svelte' import rootConfig from './root.eslint.config.js' @@ -8,10 +9,16 @@ export default [ ...pluginSvelte.configs['flat/recommended'], { rules: { - 'vitest/expect-expect': 'warn', 'svelte/block-lang': ['error', { script: ['ts'] }], 'svelte/no-svelte-internal': 'error', 'svelte/valid-compile': 'off', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/svelte-query-persist-client/eslint.config.js b/packages/svelte-query-persist-client/eslint.config.js index 62bc0c16c31..b40d00982ab 100644 --- a/packages/svelte-query-persist-client/eslint.config.js +++ b/packages/svelte-query-persist-client/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginSvelte from 'eslint-plugin-svelte' import rootConfig from './root.eslint.config.js' @@ -8,10 +9,16 @@ export default [ ...pluginSvelte.configs['flat/recommended'], { rules: { - 'vitest/expect-expect': 'warn', 'svelte/block-lang': ['error', { script: ['ts'] }], 'svelte/no-svelte-internal': 'error', 'svelte/valid-compile': 'off', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/svelte-query/eslint.config.js b/packages/svelte-query/eslint.config.js index 62bc0c16c31..b40d00982ab 100644 --- a/packages/svelte-query/eslint.config.js +++ b/packages/svelte-query/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginSvelte from 'eslint-plugin-svelte' import rootConfig from './root.eslint.config.js' @@ -8,10 +9,16 @@ export default [ ...pluginSvelte.configs['flat/recommended'], { rules: { - 'vitest/expect-expect': 'warn', 'svelte/block-lang': ['error', { script: ['ts'] }], 'svelte/no-svelte-internal': 'error', 'svelte/valid-compile': 'off', }, }, + { + plugins: { vitest }, + rules: { + ...vitest.configs.recommended.rules, + 'vitest/expect-expect': 'warn', + }, + }, ] diff --git a/packages/vue-query-devtools/eslint.config.js b/packages/vue-query-devtools/eslint.config.js index 273b4778a99..0810a2d674c 100644 --- a/packages/vue-query-devtools/eslint.config.js +++ b/packages/vue-query-devtools/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' // @ts-expect-error import pluginVue from 'eslint-plugin-vue' import rootConfig from './root.eslint.config.js' @@ -8,7 +9,9 @@ export default [ ...rootConfig, ...pluginVue.configs['flat/base'], { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, diff --git a/packages/vue-query/eslint.config.js b/packages/vue-query/eslint.config.js index 273b4778a99..0810a2d674c 100644 --- a/packages/vue-query/eslint.config.js +++ b/packages/vue-query/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' // @ts-expect-error import pluginVue from 'eslint-plugin-vue' import rootConfig from './root.eslint.config.js' @@ -8,7 +9,9 @@ export default [ ...rootConfig, ...pluginVue.configs['flat/base'], { + plugins: { vitest }, rules: { + ...vitest.configs.recommended.rules, 'vitest/expect-expect': 'warn', }, }, From 6e9b756e9a05d6a8fd684613b99a2de197c51cde Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Mon, 5 May 2025 23:15:19 +0900 Subject: [PATCH 5/5] chore(react-query-devtools): add vitest ESLint plugin to configuration --- packages/react-query-devtools/eslint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-query-devtools/eslint.config.js b/packages/react-query-devtools/eslint.config.js index 7881794de72..9133d598946 100644 --- a/packages/react-query-devtools/eslint.config.js +++ b/packages/react-query-devtools/eslint.config.js @@ -1,5 +1,6 @@ // @ts-check +import vitest from '@vitest/eslint-plugin' import pluginReact from '@eslint-react/eslint-plugin' import pluginReactHooks from 'eslint-plugin-react-hooks' import rootConfig from './root.eslint.config.js'