Skip to content

Commit ca76777

Browse files
authored
chore: force type import (TanStack#4202)
* chore: force type import * lint: prettier format * lint: rollback some eslint config * lint: fix react-query-tools
1 parent 7f8d4a0 commit ca76777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+130
-162
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"react/jsx-key": ["error", { "checkFragmentShorthand": true }],
3535
"@typescript-eslint/ban-types": "off",
3636
"@typescript-eslint/ban-ts-comment": "off",
37+
"@typescript-eslint/consistent-type-imports": "error",
3738
"@typescript-eslint/explicit-module-boundary-types": "off",
3839
"@typescript-eslint/no-empty-interface": "off",
3940
"@typescript-eslint/no-explicit-any": "off",

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Auto detect text files and perform LF normalization
2-
* text=auto
2+
* text=auto eol=lf

packages/query-async-storage-persister/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
PersistedClient,
33
Persister,
44
Promisable,

packages/query-core/src/infiniteQueryObserver.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ import type {
88
QueryKey,
99
} from './types'
1010
import type { QueryClient } from './queryClient'
11-
import {
12-
NotifyOptions,
13-
ObserverFetchOptions,
14-
QueryObserver,
15-
} from './queryObserver'
11+
import type { NotifyOptions, ObserverFetchOptions } from './queryObserver'
12+
import { QueryObserver } from './queryObserver'
1613
import {
1714
hasNextPage,
1815
hasPreviousPage,
1916
infiniteQueryBehavior,
2017
} from './infiniteQueryBehavior'
21-
import { Query } from './query'
18+
import type { Query } from './query'
2219

2320
type InfiniteQueryObserverListener<TData, TError> = (
2421
result: InfiniteQueryObserverResult<TData, TError>,

packages/query-core/src/mutation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { MutationOptions, MutationStatus, MutationMeta } from './types'
22
import type { MutationCache } from './mutationCache'
33
import type { MutationObserver } from './mutationObserver'
4-
import { defaultLogger, Logger } from './logger'
4+
import type { Logger } from './logger'
5+
import { defaultLogger } from './logger'
56
import { notifyManager } from './notifyManager'
67
import { Removable } from './removable'
7-
import { canFetch, Retryer, createRetryer } from './retryer'
8+
import type { Retryer } from './retryer'
9+
import { canFetch, createRetryer } from './retryer'
810

911
// TYPES
1012

packages/query-core/src/mutationCache.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { MutationObserver } from './mutationObserver'
1+
import type { MutationObserver } from './mutationObserver'
22
import type { MutationOptions } from './types'
33
import type { QueryClient } from './queryClient'
44
import { notifyManager } from './notifyManager'
5-
import { Action, Mutation, MutationState } from './mutation'
6-
import { matchMutation, MutationFilters, noop } from './utils'
5+
import type { Action, MutationState } from './mutation'
6+
import { Mutation } from './mutation'
7+
import type { MutationFilters } from './utils'
8+
import { matchMutation, noop } from './utils'
79
import { Subscribable } from './subscribable'
810

911
// TYPES

packages/query-core/src/mutationObserver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Action, getDefaultState, Mutation } from './mutation'
1+
import type { Action, Mutation } from './mutation'
2+
import { getDefaultState } from './mutation'
23
import { notifyManager } from './notifyManager'
34
import type { QueryClient } from './queryClient'
45
import { Subscribable } from './subscribable'

packages/query-core/src/queriesObserver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import type {
66
DefaultedQueryObserverOptions,
77
} from './types'
88
import type { QueryClient } from './queryClient'
9-
import { NotifyOptions, QueryObserver } from './queryObserver'
9+
import type { NotifyOptions } from './queryObserver'
10+
import { QueryObserver } from './queryObserver'
1011
import { Subscribable } from './subscribable'
1112

1213
type QueriesObserverListener = (result: QueryObserverResult[]) => void

packages/query-core/src/query.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import type {
1212
} from './types'
1313
import type { QueryCache } from './queryCache'
1414
import type { QueryObserver } from './queryObserver'
15-
import { defaultLogger, Logger } from './logger'
15+
import type { Logger } from './logger'
16+
import { defaultLogger } from './logger'
1617
import { notifyManager } from './notifyManager'
17-
import { Retryer, isCancelledError, canFetch, createRetryer } from './retryer'
18+
import type { Retryer } from './retryer'
19+
import { isCancelledError, canFetch, createRetryer } from './retryer'
1820
import { Removable } from './removable'
1921

2022
// TYPES

packages/query-core/src/queryCache.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import {
2-
QueryFilters,
3-
hashQueryKeyByOptions,
4-
matchQuery,
5-
parseFilterArgs,
6-
} from './utils'
7-
import { Action, Query, QueryState } from './query'
1+
import type { QueryFilters } from './utils'
2+
import { hashQueryKeyByOptions, matchQuery, parseFilterArgs } from './utils'
3+
import type { Action, QueryState } from './query'
4+
import { Query } from './query'
85
import type { QueryKey, QueryOptions } from './types'
96
import { notifyManager } from './notifyManager'
107
import type { QueryClient } from './queryClient'
118
import { Subscribable } from './subscribable'
12-
import { QueryObserver } from './queryObserver'
9+
import type { QueryObserver } from './queryObserver'
1310

1411
// TYPES
1512

packages/query-core/src/queryClient.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
import type { QueryFilters, Updater, MutationFilters } from './utils'
12
import {
2-
QueryFilters,
3-
Updater,
43
hashQueryKey,
54
noop,
65
parseFilterArgs,
76
parseQueryArgs,
87
partialMatchKey,
98
hashQueryKeyByOptions,
10-
MutationFilters,
119
functionalUpdate,
1210
} from './utils'
1311
import type {
@@ -38,8 +36,9 @@ import { focusManager } from './focusManager'
3836
import { onlineManager } from './onlineManager'
3937
import { notifyManager } from './notifyManager'
4038
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
41-
import { CancelOptions, DefaultedQueryObserverOptions } from './types'
42-
import { defaultLogger, Logger } from './logger'
39+
import type { CancelOptions, DefaultedQueryObserverOptions } from './types'
40+
import type { Logger } from './logger'
41+
import { defaultLogger } from './logger'
4342

4443
// TYPES
4544

packages/query-core/src/queryObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DefaultedQueryObserverOptions, RefetchPageFilters } from './types'
1+
import type { DefaultedQueryObserverOptions, RefetchPageFilters } from './types'
22
import {
33
isServer,
44
isValidTimeout,

packages/query-core/src/retryer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { focusManager } from './focusManager'
22
import { onlineManager } from './onlineManager'
33
import { sleep } from './utils'
4-
import { CancelOptions, NetworkMode } from './types'
4+
import type { CancelOptions, NetworkMode } from './types'
55

66
// TYPES
77

packages/query-core/src/tests/infiniteQueryBehavior.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { waitFor } from '@testing-library/react'
2-
import {
2+
import type {
33
QueryClient,
4-
InfiniteQueryObserver,
54
InfiniteQueryObserverResult,
65
} from '@tanstack/query-core'
6+
import { InfiniteQueryObserver } from '@tanstack/query-core'
77
import { createQueryClient, queryKey } from './utils'
88

99
describe('InfiniteQueryBehavior', () => {

packages/query-core/src/tests/infiniteQueryObserver.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createQueryClient, queryKey, sleep } from './utils'
2-
import { QueryClient, InfiniteQueryObserver } from '..'
2+
import type { QueryClient } from '..'
3+
import { InfiniteQueryObserver } from '..'
34

45
describe('InfiniteQueryObserver', () => {
56
let queryClient: QueryClient

packages/query-core/src/tests/mutationObserver.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { waitFor } from '@testing-library/react'
22
import { createQueryClient, sleep } from './utils'
3-
import { QueryClient, MutationObserver } from '..'
3+
import type { QueryClient } from '..'
4+
import { MutationObserver } from '..'
45

56
describe('mutationObserver', () => {
67
let queryClient: QueryClient

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { QueryClient } from '..'
1+
import type { QueryClient } from '..'
22
import { createQueryClient, executeMutation, queryKey, sleep } from './utils'
3-
import { MutationState } from '../mutation'
3+
import type { MutationState } from '../mutation'
44
import { MutationObserver } from '../mutationObserver'
55

66
describe('mutations', () => {

packages/query-core/src/tests/queriesObserver.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { waitFor } from '@testing-library/react'
22
import { sleep, queryKey, createQueryClient, mockLogger } from './utils'
3-
import {
4-
QueryClient,
5-
QueriesObserver,
6-
QueryObserverResult,
7-
QueryObserver,
8-
} from '..'
9-
import { QueryKey } from '..'
3+
import type { QueryClient, QueryObserverResult } from '..'
4+
import { QueriesObserver, QueryObserver } from '..'
5+
import type { QueryKey } from '..'
106

117
describe('queriesObserver', () => {
128
let queryClient: QueryClient

packages/query-core/src/tests/query.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import {
55
mockLogger,
66
createQueryClient,
77
} from './utils'
8-
import {
8+
import type {
99
QueryCache,
1010
QueryClient,
11-
QueryObserver,
12-
isCancelledError,
13-
isError,
14-
onlineManager,
1511
QueryFunctionContext,
1612
QueryObserverResult,
1713
} from '..'
14+
import { QueryObserver, isCancelledError, isError, onlineManager } from '..'
1815
import { waitFor } from '@testing-library/react'
1916

2017
describe('query', () => {

packages/query-core/src/tests/queryCache.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { sleep, queryKey, createQueryClient } from './utils'
2-
import { QueryCache, QueryClient } from '..'
3-
import { Query } from '.././query'
2+
import type { QueryClient } from '..'
3+
import { QueryCache } from '..'
4+
import type { Query } from '.././query'
45

56
describe('queryCache', () => {
67
let queryClient: QueryClient

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { waitFor } from '@testing-library/react'
22
import '@testing-library/jest-dom'
33

44
import { sleep, queryKey, mockLogger, createQueryClient } from './utils'
5-
import {
6-
InfiniteQueryObserver,
5+
import type {
76
QueryCache,
87
QueryClient,
98
QueryFunction,
10-
QueryObserver,
119
QueryObserverOptions,
1210
} from '..'
11+
import { InfiniteQueryObserver, QueryObserver } from '..'
1312
import { focusManager, onlineManager } from '..'
1413

1514
describe('queryClient', () => {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ import {
55
mockLogger,
66
createQueryClient,
77
} from './utils'
8-
import {
9-
QueryClient,
10-
QueryObserver,
11-
QueryObserverResult,
12-
focusManager,
13-
} from '..'
8+
import type { QueryClient, QueryObserverResult } from '..'
9+
import { QueryObserver, focusManager } from '..'
1410

1511
describe('queryObserver', () => {
1612
let queryClient: QueryClient

packages/query-core/src/tests/utils.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { act } from '@testing-library/react'
22

3-
import {
4-
MutationOptions,
5-
QueryClient,
6-
QueryClientConfig,
7-
} from '@tanstack/query-core'
3+
import type { MutationOptions, QueryClientConfig } from '@tanstack/query-core'
4+
import { QueryClient } from '@tanstack/query-core'
85
import * as utils from '../utils'
96

107
export function createQueryClient(config?: QueryClientConfig): QueryClient {

packages/query-core/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { RetryValue, RetryDelayValue } from './retryer'
44
import type { QueryFilters, QueryTypeFilter } from './utils'
55
import type { QueryCache } from './queryCache'
66
import type { MutationCache } from './mutationCache'
7-
import { Logger } from './logger'
7+
import type { Logger } from './logger'
88

99
export type QueryKey = readonly unknown[]
1010

packages/query-sync-storage-persister/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
PersistedClient,
33
Persister,
44
PersistRetryer,

packages/react-query-devtools/src/__tests__/devtools.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import * as React from 'react'
22
import { fireEvent, screen, waitFor, act } from '@testing-library/react'
33
import { ErrorBoundary } from 'react-error-boundary'
44
import '@testing-library/jest-dom'
5-
import { useQuery, QueryClient } from '@tanstack/react-query'
5+
import type { QueryClient } from '@tanstack/react-query'
6+
import { useQuery } from '@tanstack/react-query'
67
import { sortFns } from '../utils'
78
import {
89
getByTextContent,

packages/react-query-devtools/src/__tests__/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MatcherFunction } from '@testing-library/dom/types/matches'
1+
import type { MatcherFunction } from '@testing-library/dom/types/matches'
22
import { render } from '@testing-library/react'
33
import * as React from 'react'
44
import { ReactQueryDevtools } from '../devtools'

packages/react-query-devtools/src/devtools.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import * as React from 'react'
22
import { useSyncExternalStore } from './useSyncExternalStore'
3-
import {
4-
useQueryClient,
5-
onlineManager,
6-
notifyManager,
3+
import type {
74
QueryCache,
85
QueryClient,
96
QueryKey as QueryKeyType,
107
ContextOptions,
118
} from '@tanstack/react-query'
9+
import {
10+
useQueryClient,
11+
onlineManager,
12+
notifyManager,
13+
} from '@tanstack/react-query'
1214
import { rankItem, compareItems } from '@tanstack/match-sorter-utils'
1315
import useLocalStorage from './useLocalStorage'
1416
import { sortFns, useIsMounted } from './utils'

packages/react-query-devtools/src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react'
22
import type { Query } from '@tanstack/react-query'
33

4-
import { Theme, useTheme } from './theme'
4+
import type { Theme } from './theme'
5+
import { useTheme } from './theme'
56
import useMediaQuery from './useMediaQuery'
67

78
type StyledComponent<T> = T extends 'button'

packages/react-query-persist-client/src/PersistQueryClientProvider.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as React from 'react'
22

3-
import { persistQueryClient, PersistQueryClientOptions } from './persist'
4-
import {
5-
QueryClientProvider,
6-
QueryClientProviderProps,
7-
IsRestoringProvider,
8-
} from '@tanstack/react-query'
3+
import type { PersistQueryClientOptions } from './persist'
4+
import { persistQueryClient } from './persist'
5+
import type { QueryClientProviderProps } from '@tanstack/react-query'
6+
import { QueryClientProvider, IsRestoringProvider } from '@tanstack/react-query'
97

108
export type PersistQueryClientProviderProps = QueryClientProviderProps & {
119
persistOptions: Omit<PersistQueryClientOptions, 'queryClient'>

packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import * as React from 'react'
22
import { render, waitFor } from '@testing-library/react'
33

4-
import {
5-
QueryClient,
6-
useQuery,
4+
import type {
75
UseQueryResult,
8-
useQueries,
96
DefinedUseQueryResult,
107
} from '@tanstack/react-query'
8+
import { QueryClient, useQuery, useQueries } from '@tanstack/react-query'
119
import { createQueryClient, mockLogger, queryKey, sleep } from './utils'
12-
import { PersistedClient, Persister, persistQueryClientSave } from '../persist'
10+
import type { PersistedClient, Persister } from '../persist'
11+
import { persistQueryClientSave } from '../persist'
1312
import { PersistQueryClientProvider } from '../PersistQueryClientProvider'
1413

1514
const createMockPersister = (): Persister => {

0 commit comments

Comments
 (0)