Skip to content

Commit 9500a85

Browse files
committed
Remove unused ESLint disable directives
1 parent 8704baa commit 9500a85

13 files changed

+47
-61
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
@@ -114,7 +114,7 @@ export interface Slice<
114114
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`.
115115
*/
116116
get selectors(): Id<
117-
SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]: State }>
117+
SliceDefinedSelectors<State, Selectors, Record<ReducerPath, State>>
118118
>
119119

120120
/**
@@ -136,7 +136,7 @@ export interface Slice<
136136
*
137137
* Will throw an error if slice is not found.
138138
*/
139-
selectSlice(state: { [K in ReducerPath]: State }): State
139+
selectSlice(state: Record<ReducerPath, State>): State
140140
}
141141

142142
/**
@@ -175,7 +175,7 @@ type InjectedSlice<
175175
SliceDefinedSelectors<
176176
State,
177177
Selectors,
178-
{ [K in ReducerPath]?: State | undefined }
178+
Partial<Record<ReducerPath, State | undefined>>
179179
>
180180
>
181181

@@ -184,7 +184,7 @@ type InjectedSlice<
184184
*
185185
* Returns initial state if slice is not found.
186186
*/
187-
selectSlice(state: { [K in ReducerPath]?: State | undefined }): State
187+
selectSlice(state: Partial<Record<ReducerPath, State | undefined>>): State
188188
}
189189

190190
/**
@@ -423,9 +423,10 @@ export type SliceCaseReducers<State> =
423423
/**
424424
* The type describing a slice's `selectors` option.
425425
*/
426-
export type SliceSelectors<State> = {
427-
[K: string]: (sliceState: State, ...args: any[]) => any
428-
}
426+
export type SliceSelectors<State> = Record<
427+
string,
428+
(sliceState: State, ...args: any[]) => any
429+
>
429430

430431
type SliceActionType<
431432
SliceName extends string,
@@ -747,7 +748,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
747748
Slice<State, CaseReducers, Name, CurrentReducerPath, Selectors>,
748749
'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath'
749750
> {
750-
function selectSlice(state: { [K in CurrentReducerPath]: State }) {
751+
function selectSlice(state: Record<CurrentReducerPath, State>) {
751752
let sliceState = state[reducerPath]
752753
if (typeof sliceState === 'undefined') {
753754
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,
@@ -293,9 +292,9 @@ describe('Unsorted State Adapter', () => {
293292
entities: { b: { id: 'b', title: 'First' }, c: { id: 'c' } }
294293
}
295294
We now expect that only 'c' will be left:
296-
{
297-
ids: [ 'c' ],
298-
entities: { c: { id: 'c', title: 'First' } }
295+
{
296+
ids: [ 'c' ],
297+
entities: { c: { id: 'c', title: 'First' } }
299298
}
300299
*/
301300
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/buildThunks.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ import {
3939
isQueryDefinition,
4040
} from '../endpointDefinitions'
4141
import { HandledError } from '../HandledError'
42+
import {
43+
NamedSchemaError,
44+
parseWithSchema,
45+
shouldSkip,
46+
} from '../standardSchema'
4247
import type { UnwrapPromise } from '../tsHelpers'
4348
import type {
4449
InfiniteData,
@@ -68,11 +73,6 @@ import {
6873
isRejected,
6974
isRejectedWithValue,
7075
} from './rtkImports'
71-
import {
72-
parseWithSchema,
73-
NamedSchemaError,
74-
shouldSkip,
75-
} from '../standardSchema'
7676

7777
export type BuildThunksApiEndpointQuery<
7878
Definition extends QueryDefinition<any, any, any, any, any>,
@@ -391,12 +391,12 @@ export function buildThunks<
391391
)
392392
}
393393

394-
function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {
394+
function addToStart<T>(items: T[], item: T, max = 0): T[] {
395395
const newItems = [item, ...items]
396396
return max && newItems.length > max ? newItems.slice(0, -1) : newItems
397397
}
398398

399-
function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {
399+
function addToEnd<T>(items: T[], item: T, max = 0): T[] {
400400
const newItems = [...items, item]
401401
return max && newItems.length > max ? newItems.slice(1) : newItems
402402
}
@@ -509,7 +509,7 @@ export function buildThunks<
509509
endpointDefinition
510510

511511
try {
512-
let transformResponse: TransformCallback = defaultTransformResponse
512+
const transformResponse: TransformCallback = defaultTransformResponse
513513

514514
const baseQueryApi = {
515515
signal,
@@ -786,7 +786,7 @@ export function buildThunks<
786786
} catch (error) {
787787
let caughtError = error
788788
if (caughtError instanceof HandledError) {
789-
let transformErrorResponse = getTransformCallbackForEndpoint(
789+
const transformErrorResponse = getTransformCallbackForEndpoint(
790790
endpointDefinition,
791791
'transformErrorResponse',
792792
)
@@ -999,7 +999,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
999999
const force = hasTheForce(options) && options.force
10001000
const maxAge = hasMaxAge(options) && options.ifOlderThan
10011001

1002-
const queryAction = (force: boolean = true) => {
1002+
const queryAction = (force = true) => {
10031003
const options = { forceRefetch: force, isPrefetch: true }
10041004
return (
10051005
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
@@ -100,7 +100,6 @@ export type CoreModule =
100100
export type ThunkWithReturnValue<T> = ThunkAction<T, any, any, UnknownAction>
101101

102102
export interface ApiModules<
103-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
104103
BaseQuery extends BaseQueryFn,
105104
Definitions extends EndpointDefinitions,
106105
ReducerPath extends string,
@@ -216,9 +215,10 @@ export interface ApiModules<
216215
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
217216
*/
218217
getRunningQueriesThunk(): ThunkWithReturnValue<
219-
Array<
220-
QueryActionCreatorResult<any> | InfiniteQueryActionCreatorResult<any>
221-
>
218+
(
219+
| QueryActionCreatorResult<any>
220+
| InfiniteQueryActionCreatorResult<any>
221+
)[]
222222
>
223223

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

236236
/**
@@ -371,7 +371,7 @@ export interface ApiModules<
371371
* ```
372372
*/
373373
invalidateTags: ActionCreatorWithPayload<
374-
Array<TagDescription<TagTypes> | null | undefined>,
374+
(TagDescription<TagTypes> | null | undefined)[],
375375
string
376376
>
377377

@@ -382,12 +382,12 @@ export interface ApiModules<
382382
*/
383383
selectInvalidatedBy: (
384384
state: RootState<Definitions, string, ReducerPath>,
385-
tags: ReadonlyArray<TagDescription<TagTypes> | null | undefined>,
386-
) => Array<{
385+
tags: readonly (TagDescription<TagTypes> | null | undefined)[],
386+
) => {
387387
endpointName: string
388388
originalArgs: any
389389
queryCacheKey: string
390-
}>
390+
}[]
391391

392392
/**
393393
* A function to select all arguments currently cached for a given endpoint.
@@ -397,7 +397,7 @@ export interface ApiModules<
397397
selectCachedArgsForQuery: <QueryName extends AllQueryKeys<Definitions>>(
398398
state: RootState<Definitions, string, ReducerPath>,
399399
queryName: QueryName,
400-
) => Array<QueryArgFromAnyQuery<Definitions[QueryName]>>
400+
) => QueryArgFromAnyQuery<Definitions[QueryName]>[]
401401
}
402402
/**
403403
* Endpoints based on the input endpoints provided to `createApi`, containing `select` and `action matchers`.
@@ -427,9 +427,7 @@ export interface ApiModules<
427427
}
428428

429429
export interface ApiEndpointQuery<
430-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
431430
Definition extends QueryDefinition<any, any, any, any, any>,
432-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
433431
Definitions extends EndpointDefinitions,
434432
> extends BuildThunksApiEndpointQuery<Definition>,
435433
BuildInitiateApiEndpointQuery<Definition>,
@@ -442,9 +440,7 @@ export interface ApiEndpointQuery<
442440
}
443441

444442
export interface ApiEndpointInfiniteQuery<
445-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
446443
Definition extends InfiniteQueryDefinition<any, any, any, any, any>,
447-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
448444
Definitions extends EndpointDefinitions,
449445
> extends BuildThunksApiEndpointInfiniteQuery<Definition>,
450446
BuildInitiateApiEndpointInfiniteQuery<Definition>,
@@ -456,11 +452,8 @@ export interface ApiEndpointInfiniteQuery<
456452
Types: NonNullable<Definition['Types']>
457453
}
458454

459-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
460455
export interface ApiEndpointMutation<
461-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
462456
Definition extends MutationDefinition<any, any, any, any, any>,
463-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
464457
Definitions extends EndpointDefinitions,
465458
> extends BuildThunksApiEndpointMutation<Definition>,
466459
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]: {

packages/toolkit/src/query/retry.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import { HandledError } from './HandledError'
2424
* @param maxRetries - Maximum number of retries
2525
*/
2626
async function defaultBackoff(
27-
attempt: number = 0,
28-
maxRetries: number = 5,
27+
attempt = 0,
28+
maxRetries = 5,
2929
signal?: AbortSignal,
3030
) {
3131
const attempts = Math.min(attempt, maxRetries)
@@ -142,7 +142,6 @@ const retryWithBackoff: BaseQueryEnhancer<
142142
}
143143
let retry = 0
144144

145-
// eslint-disable-next-line no-constant-condition
146145
while (true) {
147146
// Check if aborted before each attempt
148147
failIfAborted(api.signal)

0 commit comments

Comments
 (0)