From e33dfb7eab309ca225fc7a9e1152a27726b749a3 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Sat, 10 Dec 2022 14:04:23 +0200 Subject: [PATCH] Reformat (only the files changed in the previous commit) --- .../toolkit/src/query/core/buildThunks.ts | 5 +-- packages/toolkit/src/query/createApi.ts | 7 +-- .../src/query/tests/buildHooks.test.tsx | 8 +--- .../src/tests/autoBatchEnhancer.test.ts | 8 +--- .../src/tests/configureStore.typetest.ts | 45 ++++++++++++------- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 8bb521b129..458b9edd44 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -19,10 +19,9 @@ import type { MutationDefinition, QueryArgFrom, QueryDefinition, - ResultTypeFrom} from '../endpointDefinitions'; -import { - isQueryDefinition + ResultTypeFrom, } from '../endpointDefinitions' +import { isQueryDefinition } from '../endpointDefinitions' import { calculateProvidedBy } from '../endpointDefinitions' import type { AsyncThunkPayloadCreator, Draft } from '@reduxjs/toolkit' import { diff --git a/packages/toolkit/src/query/createApi.ts b/packages/toolkit/src/query/createApi.ts index 4f548b6a90..d98116dd1e 100644 --- a/packages/toolkit/src/query/createApi.ts +++ b/packages/toolkit/src/query/createApi.ts @@ -1,11 +1,8 @@ import type { Api, ApiContext, Module, ModuleName } from './apiTypes' import type { CombinedState } from './core/apiState' import type { BaseQueryArg, BaseQueryFn } from './baseQueryTypes' -import type { - SerializeQueryArgs} from './defaultSerializeQueryArgs'; -import { - defaultSerializeQueryArgs -} from './defaultSerializeQueryArgs' +import type { SerializeQueryArgs } from './defaultSerializeQueryArgs' +import { defaultSerializeQueryArgs } from './defaultSerializeQueryArgs' import type { EndpointBuilder, EndpointDefinitions, diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx index 756dc2b75a..15998503d0 100644 --- a/packages/toolkit/src/query/tests/buildHooks.test.tsx +++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx @@ -25,12 +25,8 @@ import { import { server } from './mocks/server' import type { AnyAction } from 'redux' import type { SubscriptionOptions } from '@reduxjs/toolkit/dist/query/core/apiState' -import type { - SerializedError} from '@reduxjs/toolkit'; -import { - createListenerMiddleware, - configureStore, -} from '@reduxjs/toolkit' +import type { SerializedError } from '@reduxjs/toolkit' +import { createListenerMiddleware, configureStore } from '@reduxjs/toolkit' import { renderHook } from '@testing-library/react' import { delay } from '../../utils' diff --git a/packages/toolkit/src/tests/autoBatchEnhancer.test.ts b/packages/toolkit/src/tests/autoBatchEnhancer.test.ts index ad20fa0939..31ecf5ab28 100644 --- a/packages/toolkit/src/tests/autoBatchEnhancer.test.ts +++ b/packages/toolkit/src/tests/autoBatchEnhancer.test.ts @@ -1,11 +1,7 @@ import { configureStore } from '../configureStore' import { createSlice } from '../createSlice' -import type { - AutoBatchOptions} from '../autoBatchEnhancer'; -import { - autoBatchEnhancer, - prepareAutoBatched -} from '../autoBatchEnhancer' +import type { AutoBatchOptions } from '../autoBatchEnhancer' +import { autoBatchEnhancer, prepareAutoBatched } from '../autoBatchEnhancer' import { delay } from '../utils' import { debounce } from 'lodash' diff --git a/packages/toolkit/src/tests/configureStore.typetest.ts b/packages/toolkit/src/tests/configureStore.typetest.ts index d2420c53aa..ae7d4872c7 100644 --- a/packages/toolkit/src/tests/configureStore.typetest.ts +++ b/packages/toolkit/src/tests/configureStore.typetest.ts @@ -6,15 +6,14 @@ import type { Reducer, Store, Action, - StoreEnhancer + StoreEnhancer, } from 'redux' import { applyMiddleware } from 'redux' -import type { PayloadAction , - ConfigureStoreOptions} from '@reduxjs/toolkit' +import type { PayloadAction, ConfigureStoreOptions } from '@reduxjs/toolkit' import { configureStore, getDefaultMiddleware, - createSlice + createSlice, } from '@reduxjs/toolkit' import type { ThunkMiddleware, ThunkAction, ThunkDispatch } from 'redux-thunk' import thunk from 'redux-thunk' @@ -144,10 +143,12 @@ const _anyMiddleware: any = () => () => () => {} { const store = configureStore({ reducer: () => 0, - enhancers: [applyMiddleware(() => next => next)] + enhancers: [applyMiddleware(() => (next) => next)], }) - expectType>(store.dispatch) + expectType>( + store.dispatch + ) } configureStore({ @@ -159,7 +160,7 @@ const _anyMiddleware: any = () => () => () => {} { type SomePropertyStoreEnhancer = StoreEnhancer<{ someProperty: string }> - const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = next => { + const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = (next) => { return (reducer, preloadedState) => { return { ...next(reducer, preloadedState), @@ -168,9 +169,13 @@ const _anyMiddleware: any = () => () => () => {} } } - type AnotherPropertyStoreEnhancer = StoreEnhancer<{ anotherProperty: number }> + type AnotherPropertyStoreEnhancer = StoreEnhancer<{ + anotherProperty: number + }> - const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = next => { + const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = ( + next + ) => { return (reducer, preloadedState) => { return { ...next(reducer, preloadedState), @@ -184,7 +189,9 @@ const _anyMiddleware: any = () => () => () => {} enhancers: [somePropertyStoreEnhancer, anotherPropertyStoreEnhancer], }) - expectType>(store.dispatch) + expectType>( + store.dispatch + ) expectType(store.someProperty) expectType(store.anotherProperty) } @@ -348,7 +355,9 @@ const _anyMiddleware: any = () => () => () => {} { const store = configureStore({ reducer: reducerA, - middleware: [] as any as readonly [Middleware<(a: StateA) => boolean, StateA>], + middleware: [] as any as readonly [ + Middleware<(a: StateA) => boolean, StateA> + ], }) const result: boolean = store.dispatch(5) // @ts-expect-error @@ -532,21 +541,23 @@ const _anyMiddleware: any = () => () => () => {} initialState: null as any, reducers: { set(state) { - return state; + return state }, }, - }); + }) - function configureMyStore(options: Omit, 'reducer'>) { + function configureMyStore( + options: Omit, 'reducer'> + ) { return configureStore({ ...options, reducer: someSlice.reducer, - }); + }) } - const store = configureMyStore({}); + const store = configureMyStore({}) - expectType(store.dispatch); + expectType(store.dispatch) } {