Skip to content

Commit e390135

Browse files
committed
Remove unused ESLint disable directives
1 parent cfbe006 commit e390135

15 files changed

+67
-81
lines changed

packages/toolkit/src/createAsyncThunk.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface SerializedError {
6161
code?: string
6262
}
6363

64-
const commonProperties: Array<keyof SerializedError> = [
64+
const commonProperties: (keyof SerializedError)[] = [
6565
'name',
6666
'message',
6767
'stack',
@@ -606,7 +606,6 @@ export const createAsyncThunk = /* @__PURE__ */ (() => {
606606
}
607607

608608
if (conditionResult === false || abortController.signal.aborted) {
609-
// eslint-disable-next-line no-throw-literal
610609
throw {
611610
name: 'ConditionError',
612611
message: 'Aborted due to condition callback returning false.',

packages/toolkit/src/createSlice.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export interface Slice<
110110
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`.
111111
*/
112112
get selectors(): Id<
113-
SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]: State }>
113+
SliceDefinedSelectors<State, Selectors, Record<ReducerPath, State>>
114114
>
115115

116116
/**
@@ -132,7 +132,7 @@ export interface Slice<
132132
*
133133
* Will throw an error if slice is not found.
134134
*/
135-
selectSlice(state: { [K in ReducerPath]: State }): State
135+
selectSlice(state: Record<ReducerPath, State>): State
136136
}
137137

138138
/**
@@ -171,7 +171,7 @@ type InjectedSlice<
171171
SliceDefinedSelectors<
172172
State,
173173
Selectors,
174-
{ [K in ReducerPath]?: State | undefined }
174+
Partial<Record<ReducerPath, State | undefined>>
175175
>
176176
>
177177

@@ -180,7 +180,7 @@ type InjectedSlice<
180180
*
181181
* Returns initial state if slice is not found.
182182
*/
183-
selectSlice(state: { [K in ReducerPath]?: State | undefined }): State
183+
selectSlice(state: Partial<Record<ReducerPath, State | undefined>>): State
184184
}
185185

186186
/**
@@ -437,9 +437,10 @@ export type SliceCaseReducers<State> =
437437
/**
438438
* The type describing a slice's `selectors` option.
439439
*/
440-
export type SliceSelectors<State> = {
441-
[K: string]: (sliceState: State, ...args: any[]) => any
442-
}
440+
export type SliceSelectors<State> = Record<
441+
string,
442+
(sliceState: State, ...args: any[]) => any
443+
>
443444

444445
type SliceActionType<
445446
SliceName extends string,
@@ -759,7 +760,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
759760
Slice<State, CaseReducers, Name, CurrentReducerPath, Selectors>,
760761
'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath'
761762
> {
762-
function selectSlice(state: { [K in CurrentReducerPath]: State }) {
763+
function selectSlice(state: Record<CurrentReducerPath, State>) {
763764
let sliceState = state[reducerPath]
764765
if (typeof sliceState === 'undefined') {
765766
if (injected) {

packages/toolkit/src/entities/tests/sorted_state_adapter.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('Sorted State Adapter', () => {
2121
let state: EntityState<BookModel, string>
2222

2323
beforeAll(() => {
24-
//eslint-disable-next-line
2524
Object.defineProperty(Array.prototype, 'unwantedField', {
2625
enumerable: true,
2726
configurable: true,

packages/toolkit/src/entities/tests/unsorted_state_adapter.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import type { EntityAdapter, EntityState } from '../models'
1+
import { createNextState } from '../..'
22
import { createEntityAdapter } from '../create_adapter'
3+
import type { EntityAdapter, EntityState } from '../models'
34
import type { BookModel } from './fixtures/book'
45
import {
56
AClockworkOrange,
67
AnimalFarm,
78
TheGreatGatsby,
89
TheHobbit,
910
} from './fixtures/book'
10-
import { createNextState } from '../..'
1111

1212
describe('Unsorted State Adapter', () => {
1313
let adapter: EntityAdapter<BookModel, string>
1414
let state: EntityState<BookModel, string>
1515

1616
beforeAll(() => {
17-
//eslint-disable-next-line
1817
Object.defineProperty(Array.prototype, 'unwantedField', {
1918
enumerable: true,
2019
configurable: true,
@@ -272,9 +271,9 @@ describe('Unsorted State Adapter', () => {
272271
entities: { b: { id: 'b', title: 'First' }, c: { id: 'c' } }
273272
}
274273
We now expect that only 'c' will be left:
275-
{
276-
ids: [ 'c' ],
277-
entities: { c: { id: 'c', title: 'First' } }
274+
{
275+
ids: [ 'c' ],
276+
entities: { c: { id: 'c', title: 'First' } }
278277
}
279278
*/
280279
expect(ids.length).toBe(1)

packages/toolkit/src/entities/unsorted_state_adapter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function createUnsortedStateAdapter<T, Id extends EntityId>(
102102
}
103103

104104
function takeNewKey(
105-
keys: { [id: string]: Id },
105+
keys: Record<string, Id>,
106106
update: Update<T, Id>,
107107
state: R,
108108
): boolean {
@@ -129,12 +129,12 @@ export function createUnsortedStateAdapter<T, Id extends EntityId>(
129129
}
130130

131131
function updateManyMutably(
132-
updates: ReadonlyArray<Update<T, Id>>,
132+
updates: readonly Update<T, Id>[],
133133
state: R,
134134
): void {
135-
const newKeys: { [id: string]: Id } = {}
135+
const newKeys: Record<string, Id> = {}
136136

137-
const updatesPerEntity: { [id: string]: Update<T, Id> } = {}
137+
const updatesPerEntity: Record<string, Update<T, Id>> = {}
138138

139139
updates.forEach((update) => {
140140
// Only apply updates to entities that currently exist

packages/toolkit/src/immutableStateInvariantMiddleware.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ function trackProperties(
3535
isImmutable: IsImmutableFunc,
3636
ignorePaths: IgnorePaths = [],
3737
obj: Record<string, any>,
38-
path: string = '',
39-
checkedObjects: Set<Record<string, any>> = new Set(),
38+
path = '',
39+
checkedObjects = new Set<Record<string, any>>(),
4040
) {
4141
const tracked: Partial<TrackedProperty> = { value: obj }
4242

@@ -66,8 +66,8 @@ function detectMutations(
6666
ignoredPaths: IgnorePaths = [],
6767
trackedProperty: TrackedProperty,
6868
obj: any,
69-
sameParentRef: boolean = false,
70-
path: string = '',
69+
sameParentRef = false,
70+
path = '',
7171
): { wasMutated: boolean; path?: string } {
7272
const prevObj = trackedProperty ? trackedProperty.value : undefined
7373

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import type { BaseQueryError } from '../baseQueryTypes'
33
import type {
44
BaseEndpointDefinition,
55
EndpointDefinitions,
6+
InfiniteQueryDefinition,
67
MutationDefinition,
8+
PageParamFrom,
79
QueryArgFrom,
810
QueryDefinition,
911
ResultTypeFrom,
@@ -30,9 +32,9 @@ export type RefetchConfigOptions = {
3032

3133
export type PageParamFunction<DataType, PageParam> = (
3234
firstPage: DataType,
33-
allPages: Array<DataType>,
35+
allPages: DataType[],
3436
firstPageParam: PageParam,
35-
allPageParams: Array<PageParam>,
37+
allPageParams: PageParam[],
3638
) => PageParam | undefined | null
3739

3840
export type InfiniteQueryConfigOptions<DataType, PageParam> = {
@@ -59,8 +61,8 @@ export type InfiniteQueryConfigOptions<DataType, PageParam> = {
5961
}
6062

6163
export interface InfiniteData<DataType, PageParam> {
62-
pages: Array<DataType>
63-
pageParams: Array<PageParam>
64+
pages: DataType[]
65+
pageParams: PageParam[]
6466
}
6567

6668
/**
@@ -146,7 +148,7 @@ export type SubscriptionOptions = {
146148
*/
147149
refetchOnFocus?: boolean
148150
}
149-
export type Subscribers = { [requestId: string]: SubscriptionOptions }
151+
export type Subscribers = Record<string, SubscriptionOptions>
150152
export type QueryKeys<Definitions extends EndpointDefinitions> = {
151153
[K in keyof Definitions]: Definitions[K] extends QueryDefinition<
152154
any,
@@ -306,23 +308,20 @@ export type CombinedState<
306308
config: ConfigState<ReducerPath>
307309
}
308310

309-
export type InvalidationState<TagTypes extends string> = {
310-
[_ in TagTypes]: {
311-
[id: string]: Array<QueryCacheKey>
312-
[id: number]: Array<QueryCacheKey>
311+
export type InvalidationState<TagTypes extends string> = Record<
312+
TagTypes,
313+
{
314+
[id: string]: QueryCacheKey[]
315+
[id: number]: QueryCacheKey[]
313316
}
314-
}
317+
>
315318

316-
export type QueryState<D extends EndpointDefinitions> = {
317-
[queryCacheKey: string]:
318-
| QuerySubState<D[string]>
319-
| InfiniteQuerySubState<D[string]>
320-
| undefined
321-
}
319+
export type QueryState<D extends EndpointDefinitions> = Record<
320+
string,
321+
QuerySubState<D[string]> | InfiniteQuerySubState<D[string]> | undefined
322+
>
322323

323-
export type SubscriptionState = {
324-
[queryCacheKey: string]: Subscribers | undefined
325-
}
324+
export type SubscriptionState = Record<string, Subscribers | undefined>
326325

327326
export type ConfigState<ReducerPath> = RefetchConfigOptions & {
328327
reducerPath: ReducerPath
@@ -336,9 +335,10 @@ export type ModifiableConfigState = {
336335
invalidationBehavior: 'delayed' | 'immediately'
337336
} & RefetchConfigOptions
338337

339-
export type MutationState<D extends EndpointDefinitions> = {
340-
[requestId: string]: MutationSubState<D[string]> | undefined
341-
}
338+
export type MutationState<D extends EndpointDefinitions> = Record<
339+
string,
340+
MutationSubState<D[string]> | undefined
341+
>
342342

343343
export type RootState<
344344
Definitions extends EndpointDefinitions,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,19 @@ export function buildInitiate({
272272
api: Api<any, EndpointDefinitions, any, any>
273273
context: ApiContext<EndpointDefinitions>
274274
}) {
275-
const runningQueries: Map<
275+
const runningQueries = new Map<
276276
Dispatch,
277277
Record<
278278
string,
279279
| QueryActionCreatorResult<any>
280280
| InfiniteQueryActionCreatorResult<any>
281281
| undefined
282282
>
283-
> = new Map()
284-
const runningMutations: Map<
283+
>()
284+
const runningMutations = new Map<
285285
Dispatch,
286286
Record<string, MutationActionCreatorResult<any> | undefined>
287-
> = new Map()
287+
>()
288288

289289
const {
290290
unsubscribeQueryResult,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,12 @@ export function buildThunks<
370370
)
371371
}
372372

373-
function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {
373+
function addToStart<T>(items: T[], item: T, max = 0): T[] {
374374
const newItems = [item, ...items]
375375
return max && newItems.length > max ? newItems.slice(0, -1) : newItems
376376
}
377377

378-
function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {
378+
function addToEnd<T>(items: T[], item: T, max = 0): T[] {
379379
const newItems = [...items, item]
380380
return max && newItems.length > max ? newItems.slice(1) : newItems
381381
}
@@ -488,7 +488,7 @@ export function buildThunks<
488488
const endpointDefinition = endpointDefinitions[arg.endpointName]
489489

490490
try {
491-
let transformResponse: TransformCallback =
491+
const transformResponse: TransformCallback =
492492
getTransformCallbackForEndpoint(endpointDefinition, 'transformResponse')
493493

494494
const baseQueryApi = {
@@ -707,7 +707,7 @@ export function buildThunks<
707707
} catch (error) {
708708
let catchedError = error
709709
if (catchedError instanceof HandledError) {
710-
let transformErrorResponse: TransformCallback =
710+
const transformErrorResponse: TransformCallback =
711711
getTransformCallbackForEndpoint(
712712
endpointDefinition,
713713
'transformErrorResponse',
@@ -869,7 +869,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
869869
const force = hasTheForce(options) && options.force
870870
const maxAge = hasMaxAge(options) && options.ifOlderThan
871871

872-
const queryAction = (force: boolean = true) => {
872+
const queryAction = (force = true) => {
873873
const options = { forceRefetch: force, isPrefetch: true }
874874
return (
875875
api.endpoints[endpointName] as ApiEndpointQuery<any, any>

0 commit comments

Comments
 (0)