Skip to content

Commit

Permalink
chore: force type import (#4202)
Browse files Browse the repository at this point in the history
* chore: force type import

* lint: prettier format

* lint: rollback some eslint config

* lint: fix react-query-tools
  • Loading branch information
Jungzl authored Sep 23, 2022
1 parent 7f8d4a0 commit ca76777
Show file tree
Hide file tree
Showing 52 changed files with 130 additions and 162 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"react/jsx-key": ["error", { "checkFragmentShorthand": true }],
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=auto eol=lf
2 changes: 1 addition & 1 deletion packages/query-async-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
PersistedClient,
Persister,
Promisable,
Expand Down
9 changes: 3 additions & 6 deletions packages/query-core/src/infiniteQueryObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import type {
QueryKey,
} from './types'
import type { QueryClient } from './queryClient'
import {
NotifyOptions,
ObserverFetchOptions,
QueryObserver,
} from './queryObserver'
import type { NotifyOptions, ObserverFetchOptions } from './queryObserver'
import { QueryObserver } from './queryObserver'
import {
hasNextPage,
hasPreviousPage,
infiniteQueryBehavior,
} from './infiniteQueryBehavior'
import { Query } from './query'
import type { Query } from './query'

type InfiniteQueryObserverListener<TData, TError> = (
result: InfiniteQueryObserverResult<TData, TError>,
Expand Down
6 changes: 4 additions & 2 deletions packages/query-core/src/mutation.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { MutationOptions, MutationStatus, MutationMeta } from './types'
import type { MutationCache } from './mutationCache'
import type { MutationObserver } from './mutationObserver'
import { defaultLogger, Logger } from './logger'
import type { Logger } from './logger'
import { defaultLogger } from './logger'
import { notifyManager } from './notifyManager'
import { Removable } from './removable'
import { canFetch, Retryer, createRetryer } from './retryer'
import type { Retryer } from './retryer'
import { canFetch, createRetryer } from './retryer'

// TYPES

Expand Down
8 changes: 5 additions & 3 deletions packages/query-core/src/mutationCache.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { MutationObserver } from './mutationObserver'
import type { MutationObserver } from './mutationObserver'
import type { MutationOptions } from './types'
import type { QueryClient } from './queryClient'
import { notifyManager } from './notifyManager'
import { Action, Mutation, MutationState } from './mutation'
import { matchMutation, MutationFilters, noop } from './utils'
import type { Action, MutationState } from './mutation'
import { Mutation } from './mutation'
import type { MutationFilters } from './utils'
import { matchMutation, noop } from './utils'
import { Subscribable } from './subscribable'

// TYPES
Expand Down
3 changes: 2 additions & 1 deletion packages/query-core/src/mutationObserver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Action, getDefaultState, Mutation } from './mutation'
import type { Action, Mutation } from './mutation'
import { getDefaultState } from './mutation'
import { notifyManager } from './notifyManager'
import type { QueryClient } from './queryClient'
import { Subscribable } from './subscribable'
Expand Down
3 changes: 2 additions & 1 deletion packages/query-core/src/queriesObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type {
DefaultedQueryObserverOptions,
} from './types'
import type { QueryClient } from './queryClient'
import { NotifyOptions, QueryObserver } from './queryObserver'
import type { NotifyOptions } from './queryObserver'
import { QueryObserver } from './queryObserver'
import { Subscribable } from './subscribable'

type QueriesObserverListener = (result: QueryObserverResult[]) => void
Expand Down
6 changes: 4 additions & 2 deletions packages/query-core/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import type {
} from './types'
import type { QueryCache } from './queryCache'
import type { QueryObserver } from './queryObserver'
import { defaultLogger, Logger } from './logger'
import type { Logger } from './logger'
import { defaultLogger } from './logger'
import { notifyManager } from './notifyManager'
import { Retryer, isCancelledError, canFetch, createRetryer } from './retryer'
import type { Retryer } from './retryer'
import { isCancelledError, canFetch, createRetryer } from './retryer'
import { Removable } from './removable'

// TYPES
Expand Down
13 changes: 5 additions & 8 deletions packages/query-core/src/queryCache.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {
QueryFilters,
hashQueryKeyByOptions,
matchQuery,
parseFilterArgs,
} from './utils'
import { Action, Query, QueryState } from './query'
import type { QueryFilters } from './utils'
import { hashQueryKeyByOptions, matchQuery, parseFilterArgs } from './utils'
import type { Action, QueryState } from './query'
import { Query } from './query'
import type { QueryKey, QueryOptions } from './types'
import { notifyManager } from './notifyManager'
import type { QueryClient } from './queryClient'
import { Subscribable } from './subscribable'
import { QueryObserver } from './queryObserver'
import type { QueryObserver } from './queryObserver'

// TYPES

Expand Down
9 changes: 4 additions & 5 deletions packages/query-core/src/queryClient.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import type { QueryFilters, Updater, MutationFilters } from './utils'
import {
QueryFilters,
Updater,
hashQueryKey,
noop,
parseFilterArgs,
parseQueryArgs,
partialMatchKey,
hashQueryKeyByOptions,
MutationFilters,
functionalUpdate,
} from './utils'
import type {
Expand Down Expand Up @@ -38,8 +36,9 @@ import { focusManager } from './focusManager'
import { onlineManager } from './onlineManager'
import { notifyManager } from './notifyManager'
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
import { CancelOptions, DefaultedQueryObserverOptions } from './types'
import { defaultLogger, Logger } from './logger'
import type { CancelOptions, DefaultedQueryObserverOptions } from './types'
import type { Logger } from './logger'
import { defaultLogger } from './logger'

// TYPES

Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/src/queryObserver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultedQueryObserverOptions, RefetchPageFilters } from './types'
import type { DefaultedQueryObserverOptions, RefetchPageFilters } from './types'
import {
isServer,
isValidTimeout,
Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/src/retryer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { focusManager } from './focusManager'
import { onlineManager } from './onlineManager'
import { sleep } from './utils'
import { CancelOptions, NetworkMode } from './types'
import type { CancelOptions, NetworkMode } from './types'

// TYPES

Expand Down
4 changes: 2 additions & 2 deletions packages/query-core/src/tests/infiniteQueryBehavior.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { waitFor } from '@testing-library/react'
import {
import type {
QueryClient,
InfiniteQueryObserver,
InfiniteQueryObserverResult,
} from '@tanstack/query-core'
import { InfiniteQueryObserver } from '@tanstack/query-core'
import { createQueryClient, queryKey } from './utils'

describe('InfiniteQueryBehavior', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/query-core/src/tests/infiniteQueryObserver.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createQueryClient, queryKey, sleep } from './utils'
import { QueryClient, InfiniteQueryObserver } from '..'
import type { QueryClient } from '..'
import { InfiniteQueryObserver } from '..'

describe('InfiniteQueryObserver', () => {
let queryClient: QueryClient
Expand Down
3 changes: 2 additions & 1 deletion packages/query-core/src/tests/mutationObserver.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { waitFor } from '@testing-library/react'
import { createQueryClient, sleep } from './utils'
import { QueryClient, MutationObserver } from '..'
import type { QueryClient } from '..'
import { MutationObserver } from '..'

describe('mutationObserver', () => {
let queryClient: QueryClient
Expand Down
4 changes: 2 additions & 2 deletions packages/query-core/src/tests/mutations.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QueryClient } from '..'
import type { QueryClient } from '..'
import { createQueryClient, executeMutation, queryKey, sleep } from './utils'
import { MutationState } from '../mutation'
import type { MutationState } from '../mutation'
import { MutationObserver } from '../mutationObserver'

describe('mutations', () => {
Expand Down
10 changes: 3 additions & 7 deletions packages/query-core/src/tests/queriesObserver.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { waitFor } from '@testing-library/react'
import { sleep, queryKey, createQueryClient, mockLogger } from './utils'
import {
QueryClient,
QueriesObserver,
QueryObserverResult,
QueryObserver,
} from '..'
import { QueryKey } from '..'
import type { QueryClient, QueryObserverResult } from '..'
import { QueriesObserver, QueryObserver } from '..'
import type { QueryKey } from '..'

describe('queriesObserver', () => {
let queryClient: QueryClient
Expand Down
7 changes: 2 additions & 5 deletions packages/query-core/src/tests/query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import {
mockLogger,
createQueryClient,
} from './utils'
import {
import type {
QueryCache,
QueryClient,
QueryObserver,
isCancelledError,
isError,
onlineManager,
QueryFunctionContext,
QueryObserverResult,
} from '..'
import { QueryObserver, isCancelledError, isError, onlineManager } from '..'
import { waitFor } from '@testing-library/react'

describe('query', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/query-core/src/tests/queryCache.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { sleep, queryKey, createQueryClient } from './utils'
import { QueryCache, QueryClient } from '..'
import { Query } from '.././query'
import type { QueryClient } from '..'
import { QueryCache } from '..'
import type { Query } from '.././query'

describe('queryCache', () => {
let queryClient: QueryClient
Expand Down
5 changes: 2 additions & 3 deletions packages/query-core/src/tests/queryClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { waitFor } from '@testing-library/react'
import '@testing-library/jest-dom'

import { sleep, queryKey, mockLogger, createQueryClient } from './utils'
import {
InfiniteQueryObserver,
import type {
QueryCache,
QueryClient,
QueryFunction,
QueryObserver,
QueryObserverOptions,
} from '..'
import { InfiniteQueryObserver, QueryObserver } from '..'
import { focusManager, onlineManager } from '..'

describe('queryClient', () => {
Expand Down
8 changes: 2 additions & 6 deletions packages/query-core/src/tests/queryObserver.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import {
mockLogger,
createQueryClient,
} from './utils'
import {
QueryClient,
QueryObserver,
QueryObserverResult,
focusManager,
} from '..'
import type { QueryClient, QueryObserverResult } from '..'
import { QueryObserver, focusManager } from '..'

describe('queryObserver', () => {
let queryClient: QueryClient
Expand Down
7 changes: 2 additions & 5 deletions packages/query-core/src/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { act } from '@testing-library/react'

import {
MutationOptions,
QueryClient,
QueryClientConfig,
} from '@tanstack/query-core'
import type { MutationOptions, QueryClientConfig } from '@tanstack/query-core'
import { QueryClient } from '@tanstack/query-core'
import * as utils from '../utils'

export function createQueryClient(config?: QueryClientConfig): QueryClient {
Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { RetryValue, RetryDelayValue } from './retryer'
import type { QueryFilters, QueryTypeFilter } from './utils'
import type { QueryCache } from './queryCache'
import type { MutationCache } from './mutationCache'
import { Logger } from './logger'
import type { Logger } from './logger'

export type QueryKey = readonly unknown[]

Expand Down
2 changes: 1 addition & 1 deletion packages/query-sync-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
PersistedClient,
Persister,
PersistRetryer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from 'react'
import { fireEvent, screen, waitFor, act } from '@testing-library/react'
import { ErrorBoundary } from 'react-error-boundary'
import '@testing-library/jest-dom'
import { useQuery, QueryClient } from '@tanstack/react-query'
import type { QueryClient } from '@tanstack/react-query'
import { useQuery } from '@tanstack/react-query'
import { sortFns } from '../utils'
import {
getByTextContent,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query-devtools/src/__tests__/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MatcherFunction } from '@testing-library/dom/types/matches'
import type { MatcherFunction } from '@testing-library/dom/types/matches'
import { render } from '@testing-library/react'
import * as React from 'react'
import { ReactQueryDevtools } from '../devtools'
Expand Down
10 changes: 6 additions & 4 deletions packages/react-query-devtools/src/devtools.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import * as React from 'react'
import { useSyncExternalStore } from './useSyncExternalStore'
import {
useQueryClient,
onlineManager,
notifyManager,
import type {
QueryCache,
QueryClient,
QueryKey as QueryKeyType,
ContextOptions,
} from '@tanstack/react-query'
import {
useQueryClient,
onlineManager,
notifyManager,
} from '@tanstack/react-query'
import { rankItem, compareItems } from '@tanstack/match-sorter-utils'
import useLocalStorage from './useLocalStorage'
import { sortFns, useIsMounted } from './utils'
Expand Down
3 changes: 2 additions & 1 deletion packages/react-query-devtools/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react'
import type { Query } from '@tanstack/react-query'

import { Theme, useTheme } from './theme'
import type { Theme } from './theme'
import { useTheme } from './theme'
import useMediaQuery from './useMediaQuery'

type StyledComponent<T> = T extends 'button'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as React from 'react'

import { persistQueryClient, PersistQueryClientOptions } from './persist'
import {
QueryClientProvider,
QueryClientProviderProps,
IsRestoringProvider,
} from '@tanstack/react-query'
import type { PersistQueryClientOptions } from './persist'
import { persistQueryClient } from './persist'
import type { QueryClientProviderProps } from '@tanstack/react-query'
import { QueryClientProvider, IsRestoringProvider } from '@tanstack/react-query'

export type PersistQueryClientProviderProps = QueryClientProviderProps & {
persistOptions: Omit<PersistQueryClientOptions, 'queryClient'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as React from 'react'
import { render, waitFor } from '@testing-library/react'

import {
QueryClient,
useQuery,
import type {
UseQueryResult,
useQueries,
DefinedUseQueryResult,
} from '@tanstack/react-query'
import { QueryClient, useQuery, useQueries } from '@tanstack/react-query'
import { createQueryClient, mockLogger, queryKey, sleep } from './utils'
import { PersistedClient, Persister, persistQueryClientSave } from '../persist'
import type { PersistedClient, Persister } from '../persist'
import { persistQueryClientSave } from '../persist'
import { PersistQueryClientProvider } from '../PersistQueryClientProvider'

const createMockPersister = (): Persister => {
Expand Down
Loading

0 comments on commit ca76777

Please sign in to comment.