From 95d814afdab934f36ea463861802c48308ceb963 Mon Sep 17 00:00:00 2001 From: MinhoPark Date: Wed, 17 Jul 2024 18:49:46 +0900 Subject: [PATCH] chore(utils): Ensure consistent declaration style of utility functions and standardize parameters for the sleep method (#7554) * refactor: Changed parameter names to match those in other sleep utility functions. * refactor: Most utility functions are defined as regular functions, updated this one to match. * fix: formatting --- packages/query-core/src/__tests__/utils.ts | 4 ++-- packages/query-core/src/utils.ts | 8 ++++---- packages/query-persist-client-core/src/__tests__/utils.ts | 4 ++-- packages/react-query/src/__tests__/utils.tsx | 4 ++-- packages/solid-query/src/__tests__/utils.tsx | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/query-core/src/__tests__/utils.ts b/packages/query-core/src/__tests__/utils.ts index 1beace1bde..8d876afc3c 100644 --- a/packages/query-core/src/__tests__/utils.ts +++ b/packages/query-core/src/__tests__/utils.ts @@ -32,11 +32,11 @@ export function sleep(timeout: number): Promise { }) } -export const executeMutation = ( +export function executeMutation( queryClient: QueryClient, options: MutationOptions, variables: TVariables, -) => { +) { return queryClient .getMutationCache() .build(queryClient, options) diff --git a/packages/query-core/src/utils.ts b/packages/query-core/src/utils.ts index 8b498ae1e4..f84fdcd775 100644 --- a/packages/query-core/src/utils.ts +++ b/packages/query-core/src/utils.ts @@ -340,9 +340,9 @@ function hasObjectPrototype(o: any): boolean { return Object.prototype.toString.call(o) === '[object Object]' } -export function sleep(ms: number): Promise { +export function sleep(timeout: number): Promise { return new Promise((resolve) => { - setTimeout(resolve, ms) + setTimeout(resolve, timeout) }) } @@ -378,7 +378,7 @@ export function addToStart(items: Array, item: T, max = 0): Array { export const skipToken = Symbol() export type SkipToken = typeof skipToken -export const ensureQueryFn = < +export function ensureQueryFn< TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey, >( @@ -387,7 +387,7 @@ export const ensureQueryFn = < queryHash?: string }, fetchOptions?: FetchOptions, -): QueryFunction => { +): QueryFunction { if (process.env.NODE_ENV !== 'production') { if (options.queryFn === skipToken) { console.error( diff --git a/packages/query-persist-client-core/src/__tests__/utils.ts b/packages/query-persist-client-core/src/__tests__/utils.ts index 7f05c27545..d633cf7268 100644 --- a/packages/query-persist-client-core/src/__tests__/utils.ts +++ b/packages/query-persist-client-core/src/__tests__/utils.ts @@ -13,7 +13,7 @@ export function sleep(timeout: number): Promise { }) } -export const createMockPersister = (): Persister => { +export function createMockPersister(): Persister { let storedState: PersistedClient | undefined return { @@ -30,7 +30,7 @@ export const createMockPersister = (): Persister => { } } -export const createSpyPersister = (): Persister => { +export function createSpyPersister(): Persister { return { persistClient: vi.fn(), restoreClient: vi.fn(), diff --git a/packages/react-query/src/__tests__/utils.tsx b/packages/react-query/src/__tests__/utils.tsx index 4544c39a3c..7e25177768 100644 --- a/packages/react-query/src/__tests__/utils.tsx +++ b/packages/react-query/src/__tests__/utils.tsx @@ -22,13 +22,13 @@ export function renderWithClient( } as any } -export const Blink = ({ +export function Blink({ duration, children, }: { duration: number children: React.ReactNode -}) => { +}) { const [shouldShow, setShouldShow] = React.useState(true) React.useEffect(() => { diff --git a/packages/solid-query/src/__tests__/utils.tsx b/packages/solid-query/src/__tests__/utils.tsx index 7cfaff843f..98bd80b57e 100644 --- a/packages/solid-query/src/__tests__/utils.tsx +++ b/packages/solid-query/src/__tests__/utils.tsx @@ -12,11 +12,11 @@ export function queryKey() { return [`query_${queryKeyCount}`] } -export const Blink = ( +export function Blink( props: { duration: number } & ParentProps, -) => { +) { const [shouldShow, setShouldShow] = createSignal(true) createEffect(() => {