Skip to content

Commit 9295299

Browse files
committed
Remove unused ESLint disable directives
1 parent ea7c27f commit 9295299

14 files changed

+46
-60
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',
@@ -644,7 +644,6 @@ export const createAsyncThunk = /* @__PURE__ */ (() => {
644644
}
645645

646646
if (conditionResult === false || abortController.signal.aborted) {
647-
// eslint-disable-next-line no-throw-literal
648647
throw {
649648
name: 'ConditionError',
650649
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,
@@ -761,7 +762,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
761762
Slice<State, CaseReducers, Name, CurrentReducerPath, Selectors>,
762763
'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath'
763764
> {
764-
function selectSlice(state: { [K in CurrentReducerPath]: State }) {
765+
function selectSlice(state: Record<CurrentReducerPath, State>) {
765766
let sliceState = state[reducerPath]
766767
if (typeof sliceState === 'undefined') {
767768
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/buildInitiate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,19 @@ export function buildInitiate({
278278
api: Api<any, EndpointDefinitions, any, any>
279279
context: ApiContext<EndpointDefinitions>
280280
}) {
281-
const runningQueries: Map<
281+
const runningQueries = new Map<
282282
Dispatch,
283283
Record<
284284
string,
285285
| QueryActionCreatorResult<any>
286286
| InfiniteQueryActionCreatorResult<any>
287287
| undefined
288288
>
289-
> = new Map()
290-
const runningMutations: Map<
289+
>()
290+
const runningMutations = new Map<
291291
Dispatch,
292292
Record<string, MutationActionCreatorResult<any> | undefined>
293-
> = new Map()
293+
>()
294294

295295
const {
296296
unsubscribeQueryResult,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
isQueryDefinition,
3939
} from '../endpointDefinitions'
4040
import { HandledError } from '../HandledError'
41+
import { NamedSchemaError, parseWithSchema } from '../standardSchema'
4142
import type { UnwrapPromise } from '../tsHelpers'
4243
import type {
4344
InfiniteData,
@@ -67,7 +68,6 @@ import {
6768
isRejected,
6869
isRejectedWithValue,
6970
} from './rtkImports'
70-
import { parseWithSchema, NamedSchemaError } from '../standardSchema'
7171

7272
export type BuildThunksApiEndpointQuery<
7373
Definition extends QueryDefinition<any, any, any, any, any>,
@@ -386,12 +386,12 @@ export function buildThunks<
386386
)
387387
}
388388

389-
function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {
389+
function addToStart<T>(items: T[], item: T, max = 0): T[] {
390390
const newItems = [item, ...items]
391391
return max && newItems.length > max ? newItems.slice(0, -1) : newItems
392392
}
393393

394-
function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {
394+
function addToEnd<T>(items: T[], item: T, max = 0): T[] {
395395
const newItems = [...items, item]
396396
return max && newItems.length > max ? newItems.slice(1) : newItems
397397
}
@@ -504,7 +504,7 @@ export function buildThunks<
504504
endpointDefinition
505505

506506
try {
507-
let transformResponse = getTransformCallbackForEndpoint(
507+
const transformResponse = getTransformCallbackForEndpoint(
508508
endpointDefinition,
509509
'transformResponse',
510510
)
@@ -770,7 +770,7 @@ export function buildThunks<
770770
} catch (error) {
771771
let caughtError = error
772772
if (caughtError instanceof HandledError) {
773-
let transformErrorResponse = getTransformCallbackForEndpoint(
773+
const transformErrorResponse = getTransformCallbackForEndpoint(
774774
endpointDefinition,
775775
'transformErrorResponse',
776776
)
@@ -977,7 +977,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
977977
const force = hasTheForce(options) && options.force
978978
const maxAge = hasMaxAge(options) && options.ifOlderThan
979979

980-
const queryAction = (force: boolean = true) => {
980+
const queryAction = (force = true) => {
981981
const options = { forceRefetch: force, isPrefetch: true }
982982
return (
983983
api.endpoints[endpointName] as ApiEndpointQuery<any, any>

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export type CoreModule =
9797
export type ThunkWithReturnValue<T> = ThunkAction<T, any, any, UnknownAction>
9898

9999
export interface ApiModules<
100-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
101100
BaseQuery extends BaseQueryFn,
102101
Definitions extends EndpointDefinitions,
103102
ReducerPath extends string,
@@ -213,9 +212,10 @@ export interface ApiModules<
213212
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
214213
*/
215214
getRunningQueriesThunk(): ThunkWithReturnValue<
216-
Array<
217-
QueryActionCreatorResult<any> | InfiniteQueryActionCreatorResult<any>
218-
>
215+
(
216+
| QueryActionCreatorResult<any>
217+
| InfiniteQueryActionCreatorResult<any>
218+
)[]
219219
>
220220

221221
/**
@@ -227,7 +227,7 @@ export interface ApiModules<
227227
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
228228
*/
229229
getRunningMutationsThunk(): ThunkWithReturnValue<
230-
Array<MutationActionCreatorResult<any>>
230+
MutationActionCreatorResult<any>[]
231231
>
232232

233233
/**
@@ -368,7 +368,7 @@ export interface ApiModules<
368368
* ```
369369
*/
370370
invalidateTags: ActionCreatorWithPayload<
371-
Array<TagDescription<TagTypes> | null | undefined>,
371+
(TagDescription<TagTypes> | null | undefined)[],
372372
string
373373
>
374374

@@ -379,12 +379,12 @@ export interface ApiModules<
379379
*/
380380
selectInvalidatedBy: (
381381
state: RootState<Definitions, string, ReducerPath>,
382-
tags: ReadonlyArray<TagDescription<TagTypes> | null | undefined>,
383-
) => Array<{
382+
tags: readonly (TagDescription<TagTypes> | null | undefined)[],
383+
) => {
384384
endpointName: string
385385
originalArgs: any
386386
queryCacheKey: string
387-
}>
387+
}[]
388388

389389
/**
390390
* A function to select all arguments currently cached for a given endpoint.
@@ -394,7 +394,7 @@ export interface ApiModules<
394394
selectCachedArgsForQuery: <QueryName extends AllQueryKeys<Definitions>>(
395395
state: RootState<Definitions, string, ReducerPath>,
396396
queryName: QueryName,
397-
) => Array<QueryArgFromAnyQuery<Definitions[QueryName]>>
397+
) => QueryArgFromAnyQuery<Definitions[QueryName]>[]
398398
}
399399
/**
400400
* Endpoints based on the input endpoints provided to `createApi`, containing `select` and `action matchers`.
@@ -424,9 +424,7 @@ export interface ApiModules<
424424
}
425425

426426
export interface ApiEndpointQuery<
427-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
428427
Definition extends QueryDefinition<any, any, any, any, any>,
429-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
430428
Definitions extends EndpointDefinitions,
431429
> extends BuildThunksApiEndpointQuery<Definition>,
432430
BuildInitiateApiEndpointQuery<Definition>,
@@ -439,9 +437,7 @@ export interface ApiEndpointQuery<
439437
}
440438

441439
export interface ApiEndpointInfiniteQuery<
442-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
443440
Definition extends InfiniteQueryDefinition<any, any, any, any, any>,
444-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
445441
Definitions extends EndpointDefinitions,
446442
> extends BuildThunksApiEndpointInfiniteQuery<Definition>,
447443
BuildInitiateApiEndpointInfiniteQuery<Definition>,
@@ -453,11 +449,8 @@ export interface ApiEndpointInfiniteQuery<
453449
Types: NonNullable<Definition['Types']>
454450
}
455451

456-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
457452
export interface ApiEndpointMutation<
458-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
459453
Definition extends MutationDefinition<any, any, any, any, any>,
460-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
461454
Definitions extends EndpointDefinitions,
462455
> extends BuildThunksApiEndpointMutation<Definition>,
463456
BuildInitiateApiEndpointMutation<Definition>,

packages/toolkit/src/query/react/module.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ export type ReactHooksModule = typeof reactHooksModuleName
3737

3838
declare module '@reduxjs/toolkit/query' {
3939
export interface ApiModules<
40-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4140
BaseQuery extends BaseQueryFn,
4241
Definitions extends EndpointDefinitions,
43-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4442
ReducerPath extends string,
45-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4643
TagTypes extends string,
4744
> {
4845
[reactHooksModuleName]: {

0 commit comments

Comments
 (0)