Skip to content

Commit

Permalink
ci(vitest): update eslint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
manudeli committed Aug 14, 2024
1 parent 69d8ed4 commit baf46e8
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 41 deletions.
7 changes: 6 additions & 1 deletion configs/eslint-config-js/no-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ module.exports = {
},
overrides: [
{
files: ['*.spec.ts*', '*.test.ts*'],
files: ['*.spec.ts*', '*.test.ts*', '*.test-d.ts*'],
plugins: ['@vitest', 'jest-dom'],
extends: ['plugin:@vitest/legacy-recommended'],
settings: {
vitest: {
typecheck: true,
},
},
},
],
}
4 changes: 1 addition & 3 deletions packages/cache/src/cacheOptions.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ describe('cacheOptions', () => {
})

it('should add DataTag on cacheKey with ReturnType<typeof cacheFn>', () => {
expect(() => {
expectTypeOf(cache().cacheKey[dataTagSymbol]).toEqualTypeOf<number>()
})
expectTypeOf(cache().cacheKey[dataTagSymbol]).toEqualTypeOf<number>()
})
})
5 changes: 1 addition & 4 deletions packages/react-query-4/src/SuspenseInfiniteQuery.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SuspenseInfiniteQuery } from './SuspenseInfiniteQuery'
import type { UseSuspenseInfiniteQueryResult } from './useSuspenseInfiniteQuery'

describe('<SuspenseInfiniteQuery/>', () => {
it('type error', () => {
it('type check', () => {
;() => (
<SuspenseInfiniteQuery
queryKey={queryKey}
Expand Down Expand Up @@ -58,9 +58,6 @@ describe('<SuspenseInfiniteQuery/>', () => {
{(query) => <>{query.data.pages.filter(({ text }) => text)}</>}
</SuspenseInfiniteQuery>
)
})

it('type check', () => {
;() => (
<SuspenseInfiniteQuery queryKey={queryKey} queryFn={queryFn}>
{(query) => {
Expand Down
5 changes: 1 addition & 4 deletions packages/react-query-4/src/SuspenseQuery.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SuspenseQuery } from './SuspenseQuery'
import type { UseSuspenseQueryResult } from './useSuspenseQuery'

describe('<SuspenseQuery/>', () => {
it('type error', () => {
it('type check', () => {
;() => (
<SuspenseQuery
queryKey={queryKey}
Expand Down Expand Up @@ -57,9 +57,6 @@ describe('<SuspenseQuery/>', () => {
{(query) => <>{query.data.text}</>}
</SuspenseQuery>
)
})

it('type check', () => {
;() => (
<SuspenseQuery queryKey={queryKey} queryFn={queryFn}>
{(query) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { infiniteQueryOptions } from './infiniteQueryOptions'
import { type UseSuspenseInfiniteQueryResult, useSuspenseInfiniteQuery } from './useSuspenseInfiniteQuery'

describe('useSuspenseInfiniteQuery', () => {
it('type error', () => {
it('type check', () => {
// @ts-expect-error no arg
useSuspenseInfiniteQuery()

Expand Down Expand Up @@ -37,9 +37,7 @@ describe('useSuspenseInfiniteQuery', () => {
queryFn,
// @ts-expect-error no isPlaceholderData
}).isPlaceholderData
})

it('type check', () => {
const infiniteQuery = useSuspenseInfiniteQuery({ queryKey, queryFn })
expectTypeOf(infiniteQuery).toEqualTypeOf<UseSuspenseInfiniteQueryResult<{ text: string }>>()
expectTypeOf(infiniteQuery.data).toEqualTypeOf<InfiniteData<{ text: string }>>()
Expand Down
4 changes: 1 addition & 3 deletions packages/react-query-4/src/useSuspenseQueries.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useSuspenseQueries } from './useSuspenseQueries'
import type { UseSuspenseQueryResult } from './useSuspenseQuery'

describe('useSuspenseQueries', () => {
it('type error', () => {
it('type check', () => {
useSuspenseQueries({
queries: [
{
Expand Down Expand Up @@ -45,9 +45,7 @@ describe('useSuspenseQueries', () => {
useSuspenseQueries({})
// @ts-expect-error if no items
useSuspenseQueries()
})

it('type check', () => {
const [query, selectedQuery, selectedQueryByQueryOptions] = useSuspenseQueries({
queries: [
{ queryKey: [...queryKey, 5] as const, queryFn },
Expand Down
4 changes: 1 addition & 3 deletions packages/react-query-4/src/useSuspenseQuery.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { queryOptions } from './queryOptions'
import { type UseSuspenseQueryResult, useSuspenseQuery } from './useSuspenseQuery'

describe('useSuspenseQuery', () => {
it('type error', () => {
it('type check', () => {
//@ts-expect-error no arg
useSuspenseQuery()
useSuspenseQuery({
Expand Down Expand Up @@ -36,9 +36,7 @@ describe('useSuspenseQuery', () => {
queryFn,
//@ts-expect-error no isPlaceholderData
}).isPlaceholderData
})

it('type check', () => {
const result = useSuspenseQuery({ queryKey, queryFn })
expectTypeOf(result).toEqualTypeOf<UseSuspenseQueryResult<{ text: string }>>()
expectTypeOf(result.data).toEqualTypeOf<{ text: string }>()
Expand Down
5 changes: 1 addition & 4 deletions packages/react-query-5/src/SuspenseInfiniteQuery.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { describe, expectTypeOf, it } from 'vitest'
import { SuspenseInfiniteQuery } from './SuspenseInfiniteQuery'

describe('<SuspenseInfiniteQuery/>', () => {
it('type error', () => {
it('type check', () => {
;() => (
<SuspenseInfiniteQuery
queryKey={queryKey}
Expand Down Expand Up @@ -66,9 +66,6 @@ describe('<SuspenseInfiniteQuery/>', () => {
{(query) => <>{query.data.pages.filter(({ text }) => text)}</>}
</SuspenseInfiniteQuery>
)
})

it('type check', () => {
;() => (
<SuspenseInfiniteQuery
queryKey={queryKey}
Expand Down
5 changes: 1 addition & 4 deletions packages/react-query-5/src/SuspenseQuery.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { describe, expectTypeOf, it } from 'vitest'
import { SuspenseQuery } from './SuspenseQuery'

describe('<SuspenseQuery/>', () => {
it('type error', () => {
it('type check', () => {
;() => (
<SuspenseQuery
queryKey={queryKey}
Expand Down Expand Up @@ -56,9 +56,6 @@ describe('<SuspenseQuery/>', () => {
{(query) => <>{query.data.text}</>}
</SuspenseQuery>
)
})

it('type check', () => {
;() => (
<SuspenseQuery queryKey={queryKey} queryFn={queryFn}>
{(query) => {
Expand Down
24 changes: 12 additions & 12 deletions packages/utils/src/OmitKeyof.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('OmitKeyof', () => {
// @ts-expect-error Type does not satisfy the constraint keyof A
'z' | 'y'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
expectTypeOf<
OmitKeyof<
A,
Expand All @@ -36,7 +36,7 @@ describe('OmitKeyof', () => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
'strictly'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()

// 2. safely
expectTypeOf<
Expand All @@ -46,15 +46,15 @@ describe('OmitKeyof', () => {
// @ts-expect-error Type does not satisfy the constraint keyof A
'z' | 'y'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
expectTypeOf<
OmitKeyof<
A,
// With 'safely', OmitKeyof can use 'z' as type parameter like original Omit but This support autocomplete too yet for DX.
'z' | 'y',
'safely'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
})

it("'s number key type check", () => {
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('OmitKeyof', () => {
// @ts-expect-error Type does not satisfy the constraint keyof A
3 | 2
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
expectTypeOf<
OmitKeyof<
A,
Expand All @@ -92,7 +92,7 @@ describe('OmitKeyof', () => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
'strictly'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()

// 2. safely
expectTypeOf<
Expand All @@ -102,15 +102,15 @@ describe('OmitKeyof', () => {
// @ts-expect-error Type does not satisfy the constraint keyof A
3 | 2
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
expectTypeOf<
OmitKeyof<
A,
// With 'safely', OmitKeyof can use 3 as type parameter like original Omit but This support autocomplete too yet for DX.
3 | 2,
'safely'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
})

it("'s symbol key type check", () => {
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('OmitKeyof', () => {
// @ts-expect-error Type does not satisfy the constraint keyof A
typeof symbol3 | typeof symbol2
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
expectTypeOf<
OmitKeyof<
A,
Expand All @@ -152,7 +152,7 @@ describe('OmitKeyof', () => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
'strictly'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()

// 2. safely
expectTypeOf<
Expand All @@ -162,14 +162,14 @@ describe('OmitKeyof', () => {
// @ts-expect-error Type does not satisfy the constraint keyof A
typeof symbol3 | typeof symbol2
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
expectTypeOf<
OmitKeyof<
A,
// With 'safely', OmitKeyof can use symbol3 as type parameter like original Omit but This support autocomplete too yet for DX.
typeof symbol3 | typeof symbol2,
'safely'
>
>().toEqualTypeOf<ExpectedType>
>().toEqualTypeOf<ExpectedType>()
})
})

0 comments on commit baf46e8

Please sign in to comment.