Skip to content

Commit 0678c2e

Browse files
authored
Merge pull request #2992 from thorn0/lint1
2 parents d9374c7 + e33dfb7 commit 0678c2e

File tree

13 files changed

+55
-49
lines changed

13 files changed

+55
-49
lines changed

packages/toolkit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@
7777
"yargs": "^15.3.1"
7878
},
7979
"scripts": {
80-
"build-ci": "yarn rimraf dist && yarn tsc && node scripts/cli.js --skipExtraction",
80+
"build-ci": "yarn rimraf dist && yarn tsc && yarn lint && node scripts/cli.js --skipExtraction",
8181
"build-prepare": "npm run build-ci",
8282
"build": "yarn rimraf dist && yarn tsc && node scripts/cli.js --local --skipExtraction",
8383
"build-only": "yarn rimraf dist && yarn tsc && node scripts/cli.js --skipExtraction",
8484
"format": "prettier --write \"(src|examples)/**/*.{ts,tsx}\" \"**/*.md\"",
8585
"format:check": "prettier --list-different \"(src|examples)/**/*.{ts,tsx}\" \"docs/*/**.md\"",
86-
"lint": "eslint src examples",
86+
"lint": "eslint src",
8787
"test": "jest --runInBand",
8888
"type-tests": "yarn tsc -p src/tests/tsconfig.typetests.json && yarn tsc -p src/query/tests/tsconfig.typetests.json",
8989
"prepack": "npm run build-prepare"

packages/toolkit/src/listenerMiddleware/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ export const createListenerEntry: TypedCreateListenerEntry<unknown> = (
228228
return entry
229229
}
230230

231+
const cancelActiveListeners = (
232+
entry: ListenerEntry<unknown, Dispatch<AnyAction>>
233+
) => {
234+
entry.pending.forEach((controller) => {
235+
abortControllerWithReason(controller, listenerCancelled)
236+
})
237+
}
238+
231239
const createClearListenerMiddleware = (
232240
listenerMap: Map<string, ListenerEntry>
233241
) => {
@@ -284,14 +292,6 @@ const defaultErrorHandler: ListenerErrorHandler = (...args: unknown[]) => {
284292
console.error(`${alm}/error`, ...args)
285293
}
286294

287-
const cancelActiveListeners = (
288-
entry: ListenerEntry<unknown, Dispatch<AnyAction>>
289-
) => {
290-
entry.pending.forEach((controller) => {
291-
abortControllerWithReason(controller, listenerCancelled)
292-
})
293-
}
294-
295295
/**
296296
* @public
297297
*/

packages/toolkit/src/query/core/buildMiddleware/batchActions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import type {
66
Subscribers,
77
} from '../apiState'
88
import { produceWithPatches } from 'immer'
9-
import { createSlice, PayloadAction, AnyAction } from '@reduxjs/toolkit'
9+
import type { AnyAction } from '@reduxjs/toolkit';
10+
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
1011

1112
// Copied from https://github.com/feross/queue-microtask
1213
let promise: Promise<any>

packages/toolkit/src/query/core/buildThunks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ import type {
1212
QueryActionCreatorResult,
1313
} from './buildInitiate'
1414
import { forceQueryFnSymbol, isUpsertQuery } from './buildInitiate'
15-
import {
15+
import type {
1616
AssertTagTypes,
1717
EndpointDefinition,
1818
EndpointDefinitions,
19-
isQueryDefinition,
2019
MutationDefinition,
2120
QueryArgFrom,
2221
QueryDefinition,
2322
ResultTypeFrom,
2423
} from '../endpointDefinitions'
24+
import { isQueryDefinition } from '../endpointDefinitions'
2525
import { calculateProvidedBy } from '../endpointDefinitions'
2626
import type { AsyncThunkPayloadCreator, Draft } from '@reduxjs/toolkit'
2727
import {

packages/toolkit/src/query/createApi.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { Api, ApiContext, Module, ModuleName } from './apiTypes'
22
import type { CombinedState } from './core/apiState'
33
import type { BaseQueryArg, BaseQueryFn } from './baseQueryTypes'
4-
import {
5-
defaultSerializeQueryArgs,
6-
SerializeQueryArgs,
7-
} from './defaultSerializeQueryArgs'
4+
import type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
5+
import { defaultSerializeQueryArgs } from './defaultSerializeQueryArgs'
86
import type {
97
EndpointBuilder,
108
EndpointDefinitions,

packages/toolkit/src/query/endpointDefinitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AnyAction, ThunkDispatch } from '@reduxjs/toolkit'
2-
import { SerializeQueryArgs } from './defaultSerializeQueryArgs'
2+
import type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
33
import type { QuerySubState, RootState } from './core/apiState'
44
import type {
55
BaseQueryExtraOptions,

packages/toolkit/src/query/react/ApiProvider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { configureStore } from '@reduxjs/toolkit'
2-
import { Context, useEffect } from 'react'
2+
import type { Context } from 'react'
3+
import { useEffect } from 'react'
34
import React from 'react'
45
import type { ReactReduxContextValue } from 'react-redux'
56
import { Provider } from 'react-redux'
@@ -50,7 +51,7 @@ export function ApiProvider<A extends Api<any, {}, any, any>>(props: {
5051
props.setupListeners === false
5152
? undefined
5253
: setupListeners(store.dispatch, props.setupListeners),
53-
[props.setupListeners]
54+
[props.setupListeners, store.dispatch]
5455
)
5556

5657
return (

packages/toolkit/src/query/retry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
BaseQueryExtraOptions,
66
BaseQueryFn,
77
} from './baseQueryTypes'
8-
import { FetchBaseQueryError } from './fetchBaseQuery'
8+
import type { FetchBaseQueryError } from './fetchBaseQuery'
99
import { HandledError } from './HandledError'
1010

1111
/**

packages/toolkit/src/query/tests/buildHooks.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ import {
2525
import { server } from './mocks/server'
2626
import type { AnyAction } from 'redux'
2727
import type { SubscriptionOptions } from '@reduxjs/toolkit/dist/query/core/apiState'
28-
import {
29-
createListenerMiddleware,
30-
SerializedError,
31-
configureStore,
32-
} from '@reduxjs/toolkit'
28+
import type { SerializedError } from '@reduxjs/toolkit'
29+
import { createListenerMiddleware, configureStore } from '@reduxjs/toolkit'
3330
import { renderHook } from '@testing-library/react'
3431
import { delay } from '../../utils'
3532

packages/toolkit/src/query/tests/createApi.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from './helpers'
1818
import { server } from './mocks/server'
1919
import { rest } from 'msw'
20-
import { SerializeQueryArgs } from '../defaultSerializeQueryArgs'
20+
import type { SerializeQueryArgs } from '../defaultSerializeQueryArgs'
2121
import { string } from 'yargs'
2222

2323
const originalEnv = process.env.NODE_ENV

packages/toolkit/src/tests/autoBatchEnhancer.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { configureStore } from '../configureStore'
22
import { createSlice } from '../createSlice'
3-
import {
4-
autoBatchEnhancer,
5-
prepareAutoBatched,
6-
AutoBatchOptions,
7-
} from '../autoBatchEnhancer'
3+
import type { AutoBatchOptions } from '../autoBatchEnhancer'
4+
import { autoBatchEnhancer, prepareAutoBatched } from '../autoBatchEnhancer'
85
import { delay } from '../utils'
96
import { debounce } from 'lodash'
107

packages/toolkit/src/tests/configureStore.typetest.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import type {
66
Reducer,
77
Store,
88
Action,
9-
StoreEnhancer
9+
StoreEnhancer,
1010
} from 'redux'
1111
import { applyMiddleware } from 'redux'
12-
import type { PayloadAction } from '@reduxjs/toolkit'
12+
import type { PayloadAction, ConfigureStoreOptions } from '@reduxjs/toolkit'
1313
import {
1414
configureStore,
1515
getDefaultMiddleware,
1616
createSlice,
17-
ConfigureStoreOptions,
1817
} from '@reduxjs/toolkit'
1918
import type { ThunkMiddleware, ThunkAction, ThunkDispatch } from 'redux-thunk'
2019
import thunk from 'redux-thunk'
@@ -144,10 +143,12 @@ const _anyMiddleware: any = () => () => () => {}
144143
{
145144
const store = configureStore({
146145
reducer: () => 0,
147-
enhancers: [applyMiddleware(() => next => next)]
146+
enhancers: [applyMiddleware(() => (next) => next)],
148147
})
149148

150-
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(store.dispatch)
149+
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(
150+
store.dispatch
151+
)
151152
}
152153

153154
configureStore({
@@ -159,7 +160,7 @@ const _anyMiddleware: any = () => () => () => {}
159160
{
160161
type SomePropertyStoreEnhancer = StoreEnhancer<{ someProperty: string }>
161162

162-
const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = next => {
163+
const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = (next) => {
163164
return (reducer, preloadedState) => {
164165
return {
165166
...next(reducer, preloadedState),
@@ -168,9 +169,13 @@ const _anyMiddleware: any = () => () => () => {}
168169
}
169170
}
170171

171-
type AnotherPropertyStoreEnhancer = StoreEnhancer<{ anotherProperty: number }>
172+
type AnotherPropertyStoreEnhancer = StoreEnhancer<{
173+
anotherProperty: number
174+
}>
172175

173-
const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = next => {
176+
const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = (
177+
next
178+
) => {
174179
return (reducer, preloadedState) => {
175180
return {
176181
...next(reducer, preloadedState),
@@ -184,7 +189,9 @@ const _anyMiddleware: any = () => () => () => {}
184189
enhancers: [somePropertyStoreEnhancer, anotherPropertyStoreEnhancer],
185190
})
186191

187-
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(store.dispatch)
192+
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(
193+
store.dispatch
194+
)
188195
expectType<string>(store.someProperty)
189196
expectType<number>(store.anotherProperty)
190197
}
@@ -348,7 +355,9 @@ const _anyMiddleware: any = () => () => () => {}
348355
{
349356
const store = configureStore({
350357
reducer: reducerA,
351-
middleware: [] as any as readonly [Middleware<(a: StateA) => boolean, StateA>],
358+
middleware: [] as any as readonly [
359+
Middleware<(a: StateA) => boolean, StateA>
360+
],
352361
})
353362
const result: boolean = store.dispatch(5)
354363
// @ts-expect-error
@@ -532,21 +541,23 @@ const _anyMiddleware: any = () => () => () => {}
532541
initialState: null as any,
533542
reducers: {
534543
set(state) {
535-
return state;
544+
return state
536545
},
537546
},
538-
});
547+
})
539548

540-
function configureMyStore<S>(options: Omit<ConfigureStoreOptions<S>, 'reducer'>) {
549+
function configureMyStore<S>(
550+
options: Omit<ConfigureStoreOptions<S>, 'reducer'>
551+
) {
541552
return configureStore({
542553
...options,
543554
reducer: someSlice.reducer,
544-
});
555+
})
545556
}
546557

547-
const store = configureMyStore({});
558+
const store = configureMyStore({})
548559

549-
expectType<Function>(store.dispatch);
560+
expectType<Function>(store.dispatch)
550561
}
551562

552563
{

packages/toolkit/src/tests/injectableCombineReducers.example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const rootReducer = combineSlices(sliceA, sliceB, {
3131
// fileC.ts
3232
// "naive" approach
3333

34-
import { rootReducer, RootState } from './reducer'
34+
import type { RootState } from './reducer';
35+
import { rootReducer } from './reducer'
3536
import { createSlice } from '@reduxjs/toolkit'
3637

3738
interface SliceCState {

0 commit comments

Comments
 (0)