Skip to content

Commit ab1a353

Browse files
manudeliTkDodo
andauthored
ci(*): official @vitest/eslint-plugin (#7896)
Co-authored-by: Dominik Dorfmeister <[email protected]>
1 parent 49a8dc4 commit ab1a353

26 files changed

+335
-121
lines changed

eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// @ts-ignore Needed due to moduleResolution Node vs Bundler
44
import { tanstackConfig } from '@tanstack/config/eslint'
55
import pluginCspell from '@cspell/eslint-plugin'
6+
import vitest from '@vitest/eslint-plugin'
67

78
export default [
89
...tanstackConfig,
@@ -40,4 +41,13 @@ export default [
4041
'no-case-declarations': 'off',
4142
},
4243
},
44+
{
45+
files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'],
46+
plugins: { vitest },
47+
rules: {
48+
...vitest.configs.recommended.rules,
49+
'vitest/expect-expect': 'warn',
50+
},
51+
settings: { vitest: { typecheck: true } },
52+
},
4353
]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@types/react": "npm:types-react@rc",
5050
"@types/react-dom": "npm:types-react-dom@rc",
5151
"@vitest/coverage-istanbul": "^2.0.4",
52+
"@vitest/eslint-plugin": "^1.0.2",
5253
"cpy-cli": "^5.0.0",
5354
"esbuild-plugin-file-path-extensions": "^2.1.2",
5455
"eslint": "^8.57.0",

packages/angular-query-experimental/src/__tests__/inject-mutation-state.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('injectMutationState', () => {
3030
})
3131

3232
describe('injectMutationState', () => {
33-
test('should return variables after calling mutate', async () => {
33+
test('should return variables after calling mutate 1', async () => {
3434
const mutationKey = ['mutation']
3535
const variables = 'foo123'
3636

@@ -91,7 +91,7 @@ describe('injectMutationState', () => {
9191
expect(mutationState()).toEqual([variables2])
9292
})
9393

94-
test('should return variables after calling mutate', async () => {
94+
test('should return variables after calling mutate 2', async () => {
9595
queryClient.clear()
9696
const mutationKey = ['mutation']
9797
const variables = 'bar234'

packages/angular-query-experimental/src/util/assert-injector/assert-injector.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import { TestBed } from '@angular/core/testing'
2121
import { assertInjector } from './assert-injector'
2222

23-
describe(assertInjector.name, () => {
23+
describe('assertInjector', () => {
2424
const token = new InjectionToken('token', {
2525
factory: () => 1,
2626
})

packages/angular-query-experimental/src/util/create-injection-token/create-injection-token.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { TestBed } from '@angular/core/testing'
1515
import { createNoopInjectionToken } from './create-injection-token'
1616

17-
describe(createNoopInjectionToken.name, () => {
17+
describe('createNoopInjectionToken', () => {
1818
describe('given an injection token', () => {
1919
const [injectFn, provideFn] = createNoopInjectionToken<number, true>(
2020
'noop',

packages/query-core/src/__tests__/OmitKeyof.test-d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('OmitKeyof', () => {
2727
// @ts-expect-error Type does not satisfy the constraint keyof A
2828
'z' | 'y'
2929
>
30-
>().toEqualTypeOf<ExpectedType>
30+
>().toEqualTypeOf<ExpectedType>()
3131
expectTypeOf<
3232
OmitKeyof<
3333
A,
@@ -36,7 +36,7 @@ describe('OmitKeyof', () => {
3636
'z' | 'y',
3737
'strictly'
3838
>
39-
>().toEqualTypeOf<ExpectedType>
39+
>().toEqualTypeOf<ExpectedType>()
4040

4141
// 2. safely
4242
expectTypeOf<
@@ -46,15 +46,15 @@ describe('OmitKeyof', () => {
4646
// @ts-expect-error Type does not satisfy the constraint keyof A
4747
'z' | 'y'
4848
>
49-
>().toEqualTypeOf<ExpectedType>
49+
>().toEqualTypeOf<ExpectedType>()
5050
expectTypeOf<
5151
OmitKeyof<
5252
A,
5353
// With 'safely', OmitKeyof can use 'z' as type parameter like original Omit but This support autocomplete too yet for DX.
5454
'z' | 'y',
5555
'safely'
5656
>
57-
>().toEqualTypeOf<ExpectedType>
57+
>().toEqualTypeOf<ExpectedType>()
5858
})
5959

6060
it("'s number key type check", () => {
@@ -82,7 +82,7 @@ describe('OmitKeyof', () => {
8282
// @ts-expect-error Type does not satisfy the constraint keyof A
8383
3 | 2
8484
>
85-
>().toEqualTypeOf<ExpectedType>
85+
>().toEqualTypeOf<ExpectedType>()
8686
expectTypeOf<
8787
OmitKeyof<
8888
A,
@@ -91,7 +91,7 @@ describe('OmitKeyof', () => {
9191
3 | 2,
9292
'strictly'
9393
>
94-
>().toEqualTypeOf<ExpectedType>
94+
>().toEqualTypeOf<ExpectedType>()
9595

9696
// 2. safely
9797
expectTypeOf<
@@ -101,15 +101,15 @@ describe('OmitKeyof', () => {
101101
// @ts-expect-error Type does not satisfy the constraint keyof A
102102
3 | 2
103103
>
104-
>().toEqualTypeOf<ExpectedType>
104+
>().toEqualTypeOf<ExpectedType>()
105105
expectTypeOf<
106106
OmitKeyof<
107107
A,
108108
// With 'safely', OmitKeyof can use 3 as type parameter like original Omit but This support autocomplete too yet for DX.
109109
3 | 2,
110110
'safely'
111111
>
112-
>().toEqualTypeOf<ExpectedType>
112+
>().toEqualTypeOf<ExpectedType>()
113113
})
114114

115115
it("'s symbol key type check", () => {
@@ -143,7 +143,7 @@ describe('OmitKeyof', () => {
143143
// @ts-expect-error Type does not satisfy the constraint keyof A
144144
typeof symbol3 | typeof symbol2
145145
>
146-
>().toEqualTypeOf<ExpectedType>
146+
>().toEqualTypeOf<ExpectedType>()
147147
expectTypeOf<
148148
OmitKeyof<
149149
A,
@@ -152,7 +152,7 @@ describe('OmitKeyof', () => {
152152
typeof symbol3 | typeof symbol2,
153153
'strictly'
154154
>
155-
>().toEqualTypeOf<ExpectedType>
155+
>().toEqualTypeOf<ExpectedType>()
156156

157157
// 2. safely
158158
expectTypeOf<
@@ -162,14 +162,14 @@ describe('OmitKeyof', () => {
162162
// @ts-expect-error Type does not satisfy the constraint keyof A
163163
typeof symbol3 | typeof symbol2
164164
>
165-
>().toEqualTypeOf<ExpectedType>
165+
>().toEqualTypeOf<ExpectedType>()
166166
expectTypeOf<
167167
OmitKeyof<
168168
A,
169169
// With 'safely', OmitKeyof can use symbol3 as type parameter like original Omit but This support autocomplete too yet for DX.
170170
typeof symbol3 | typeof symbol2,
171171
'safely'
172172
>
173-
>().toEqualTypeOf<ExpectedType>
173+
>().toEqualTypeOf<ExpectedType>()
174174
})
175175
})

packages/query-core/src/__tests__/mutations.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ describe('mutations', () => {
348348
expect(error).toEqual(new Error('No mutationFn found'))
349349
})
350350

351-
test('mutate update the mutation state even without an active subscription', async () => {
351+
test('mutate update the mutation state even without an active subscription 1', async () => {
352352
const onSuccess = vi.fn()
353353
const onSettled = vi.fn()
354354

@@ -364,7 +364,7 @@ describe('mutations', () => {
364364
expect(onSettled).not.toHaveBeenCalled()
365365
})
366366

367-
test('mutate update the mutation state even without an active subscription', async () => {
367+
test('mutate update the mutation state even without an active subscription 2', async () => {
368368
const onSuccess = vi.fn()
369369
const onSettled = vi.fn()
370370

packages/query-core/src/__tests__/queryClient.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ describe('queryClient', () => {
218218
expect(testCache.find({ queryKey: key })).toBe(testCache.get('someKey'))
219219
})
220220

221-
test('should create a new query if query was not found', () => {
221+
test('should create a new query if query was not found 1', () => {
222222
const key = queryKey()
223223
queryClient.setQueryData(key, 'bar')
224224
expect(queryClient.getQueryData(key)).toBe('bar')
225225
})
226226

227-
test('should create a new query if query was not found', () => {
227+
test('should create a new query if query was not found 2', () => {
228228
const key = queryKey()
229229
queryClient.setQueryData(key, 'qux')
230230
expect(queryClient.getQueryData(key)).toBe('qux')
@@ -1074,7 +1074,7 @@ describe('queryClient', () => {
10741074
expect(queryFn2).toHaveBeenCalledTimes(1)
10751075
})
10761076

1077-
test('should be able to refetch all active and inactive queries', async () => {
1077+
test('should be able to refetch all active and inactive queries (queryClient.refetchQueries()', async () => {
10781078
const key1 = queryKey()
10791079
const key2 = queryKey()
10801080
const queryFn1 = vi
@@ -1097,7 +1097,7 @@ describe('queryClient', () => {
10971097
expect(queryFn2).toHaveBeenCalledTimes(2)
10981098
})
10991099

1100-
test('should be able to refetch all active and inactive queries', async () => {
1100+
test('should be able to refetch all active and inactive queries (queryClient.refetchQueries({ type: "all" }))', async () => {
11011101
const key1 = queryKey()
11021102
const key2 = queryKey()
11031103
const queryFn1 = vi

packages/query-core/src/__tests__/queryObserver.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe('queryObserver', () => {
157157
unsubscribe()
158158
})
159159

160-
test('should not be re-fetched if not subscribed to after enabled was toggled to true', async () => {
160+
test('should not be re-fetched if not subscribed to after enabled was toggled to true (fetchStatus: "idle")', async () => {
161161
const unsubscribe = observer.subscribe(vi.fn())
162162

163163
// Toggle enabled
@@ -175,7 +175,7 @@ describe('queryObserver', () => {
175175
expect(count).toBe(0)
176176
})
177177

178-
test('should not be re-fetched if not subscribed to after enabled was toggled to true', async () => {
178+
test('should not be re-fetched if not subscribed to after enabled was toggled to true (fetchStatus: "fetching")', async () => {
179179
const unsubscribe = observer.subscribe(vi.fn())
180180

181181
// Toggle enabled

packages/query-sync-storage-persister/src/__tests__/storageIsFull.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function getMockStorage(limitSize?: number) {
4040
} as any as Storage
4141
}
4242

43-
describe('create persister ', () => {
43+
describe('create persister', () => {
4444
test('basic store and recover', async () => {
4545
const queryCache = new QueryCache()
4646
const mutationCache = new MutationCache()

0 commit comments

Comments
 (0)