Skip to content

Commit 6379654

Browse files
authored
fix: move usage of React Context out of core package (#3578)
* refactor: move test utils out of reactjs so that we can import them in core * refactor: move react specific utils back to reactjs * refactor: adapt test imports * refactor: move two tests to the reactjs package because they render a component * chore: setup eslint import zones so that we can't import anything into `core` that lives in other packages, like reactjs * fix: move usage of React Context out of core package by keeping HydrateOptions separate from React, and only add ContextOptions where necessary
1 parent fdbc002 commit 6379654

36 files changed

+200
-193
lines changed

.eslintrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434
"import/no-cycle": "error",
3535
"import/no-unresolved": ["error", { "ignore": ["react-query"] }],
3636
"import/no-unused-modules": ["off", { "unusedExports": true }],
37+
"import/no-restricted-paths": [
38+
"error",
39+
{
40+
"zones": [
41+
{ "target": "src/core", "from": "src/broadcastQueryClient-experimental" },
42+
{ "target": "src/core", "from": "src/createAsyncStoragePersister" },
43+
{ "target": "src/core", "from": "src/createWebStoragePersister" },
44+
{ "target": "src/core", "from": "src/devtools" },
45+
{ "target": "src/core", "from": "src/persistQueryClient" },
46+
{ "target": "src/core", "from": "src/reactjs" }
47+
]
48+
}
49+
],
3750
"no-redeclare": "off"
3851
}
3952
}

src/core/hydration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ContextOptions } from '../reactjs/types'
21
import type { QueryClient } from './queryClient'
32
import type { Query, QueryState } from './query'
43
import type {
@@ -18,7 +17,7 @@ export interface DehydrateOptions {
1817
shouldDehydrateQuery?: ShouldDehydrateQueryFunction
1918
}
2019

21-
export interface HydrateOptions extends ContextOptions {
20+
export interface HydrateOptions {
2221
defaultOptions?: {
2322
queries?: QueryOptions
2423
mutations?: MutationOptions

src/core/tests/focusManager.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { sleep } from '../utils'
22
import { FocusManager } from '../focusManager'
3-
import { setIsServer } from '../../reactjs/tests/utils'
3+
import { setIsServer } from '../../tests/utils'
44

55
describe('focusManager', () => {
66
let focusManager: FocusManager

src/core/tests/hydration.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
executeMutation,
44
mockNavigatorOnLine,
55
sleep,
6-
} from '../../reactjs/tests/utils'
6+
} from '../../tests/utils'
77
import { QueryCache } from '../queryCache'
88
import { dehydrate, hydrate } from '../hydration'
99

src/core/tests/infiniteQueryBehavior.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { waitFor } from '@testing-library/react'
2-
import { createQueryClient, queryKey } from '../../reactjs/tests/utils'
32
import {
43
QueryClient,
54
InfiniteQueryObserver,
65
InfiniteQueryObserverResult,
76
} from '../..'
7+
import { createQueryClient, queryKey } from '../../tests/utils'
88

99
describe('InfiniteQueryBehavior', () => {
1010
let queryClient: QueryClient

src/core/tests/infiniteQueryObserver.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { sleep, queryKey, createQueryClient } from '../../reactjs/tests/utils'
1+
import { createQueryClient, queryKey, sleep } from '../../tests/utils'
22
import { QueryClient, InfiniteQueryObserver } from '../..'
33

44
describe('InfiniteQueryObserver', () => {

src/core/tests/mutationCache.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
sleep,
55
executeMutation,
66
createQueryClient,
7-
} from '../../reactjs/tests/utils'
7+
} from '../../tests/utils'
88
import { MutationCache, MutationObserver } from '../..'
99

1010
describe('mutationCache', () => {

src/core/tests/mutationObserver.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { waitFor } from '@testing-library/react'
2-
import { createQueryClient, sleep } from '../../reactjs/tests/utils'
2+
import { createQueryClient, sleep } from '../../tests/utils'
33
import { QueryClient, MutationObserver } from '../..'
44

55
describe('mutationObserver', () => {

src/core/tests/mutations.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
executeMutation,
55
queryKey,
66
sleep,
7-
} from '../../reactjs/tests/utils'
7+
} from '../../tests/utils'
88
import { MutationState } from '../mutation'
99
import { MutationObserver } from '../mutationObserver'
1010

src/core/tests/notifyManager.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createNotifyManager } from '../notifyManager'
2-
import { sleep } from '../../devtools/tests/utils'
2+
import { sleep } from '../../tests/utils'
33

44
describe('notifyManager', () => {
55
it('should use default notifyFn', async () => {

0 commit comments

Comments
 (0)