Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9b6b9de
Add `configs` to `workspaces`
aryaemami59 Aug 27, 2024
7781664
use foreach so publish doesn't fail if package doesn't have tests, an…
EskiMojo14 Feb 8, 2024
b6e81dc
Build `config` packages on `postinstall`
aryaemami59 Aug 27, 2024
260f923
Initialize all the `config` packages
aryaemami59 Aug 27, 2024
a7586d3
Use the shareable Prettier config
aryaemami59 Aug 27, 2024
3f14e4a
Use the shareable ESLint config
aryaemami59 Aug 27, 2024
cc7230b
Use shareable `tsconfig.json` files
aryaemami59 Aug 28, 2024
0d71b78
Use the shareable Vitest config
aryaemami59 Aug 28, 2024
dca79bc
Run `yarn format` to format all files
aryaemami59 Sep 3, 2024
6ce8871
Add `AnyNonNullishValue` helper type
aryaemami59 Sep 3, 2024
275c2e0
Add `AnyFunction` helper type
aryaemami59 Sep 3, 2024
5b9b778
Add `EmptyObject` helper type
aryaemami59 Sep 3, 2024
718d0d2
Add `AnyObject` helper type
aryaemami59 Sep 3, 2024
e70c337
Add `isObject` and `hasBodyAndHeaders` utility functions
aryaemami59 Sep 3, 2024
a69e82c
Change all `let` variables to `const` to comply with `prefer-const` rule
aryaemami59 Sep 3, 2024
dc41266
Make `hasBodyAndHeaders` assertion looser
aryaemami59 Sep 3, 2024
88d1f17
Use `hasBodyAndHeaders` to fix TS issues in `fetchBaseQuery.test.tsx`
aryaemami59 Sep 3, 2024
0170457
Fix lint issues related to the `no-prototype-builtins` rule
aryaemami59 Sep 3, 2024
137f315
Fix `no-unsafe-optional-chaining` related problems
aryaemami59 Feb 3, 2024
2f78ece
Fix `@typescript-eslint/prefer-as-const` related problems
aryaemami59 Sep 3, 2024
affc5e8
Fix `no-extra-boolean-cast` related problems
aryaemami59 Sep 3, 2024
a596a5a
Fix `no-constant-condition` related problems
aryaemami59 Feb 3, 2024
b79b9e5
Fix `no-empty` related problems
aryaemami59 Feb 3, 2024
24c50e3
Replace all `Function` references with `AnyFunction`
aryaemami59 Feb 3, 2024
61086e8
Move custom matchers into `vitest.setup.ts`
aryaemami59 Feb 8, 2024
9127134
Fix `@typescript-eslint/no-unnecessary-type-constraint` related problems
aryaemami59 Sep 3, 2024
e6778e9
Disable `prefer-rest-params` inside `composeWithDevTools`
aryaemami59 Feb 8, 2024
d9d6b89
Fix `@typescript-eslint/no-var-requires` related problems
aryaemami59 Feb 3, 2024
f232712
Fix issues related to the `@typescript-eslint/prefer-function-type` rule
aryaemami59 Feb 3, 2024
618b4e2
Fix problems related to the `@typescript-eslint/no-empty-function` rule
aryaemami59 Feb 7, 2024
51521c0
Fix problems related to the `sort-imports` rule
aryaemami59 Sep 3, 2024
8704baa
Replace all `{}` types with `AnyNonNullishValue`
aryaemami59 Feb 3, 2024
9500a85
Remove unused ESLint disable directives
aryaemami59 Sep 4, 2024
a143442
Fix `@typescript-eslint/no-unused-expressions` related issues
aryaemami59 Jul 31, 2024
147cb81
Fix problems related to the `@typescript-eslint/array-type` rule
aryaemami59 Sep 4, 2024
48e889d
Fix `noImplicitReturns`-related issues in `src/tests/utils/helpers.tsx`
aryaemami59 Sep 4, 2024
a93bc7d
Fix issues related to `hasBodyAndHeaders` usage
aryaemami59 Sep 4, 2024
2d307b2
Lint files and check formatting during CI
aryaemami59 Sep 4, 2024
c7c2d3c
Fix TS issues related to `AnyNonNullishValue`
aryaemami59 Sep 5, 2024
d2f46c9
Fix TS issues related to `EmptyObject`
aryaemami59 Sep 5, 2024
2854438
Remove unused imports
aryaemami59 Sep 21, 2024
bc933f4
Resolve remaining lint errors
aryaemami59 Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused ESLint disable directives
  • Loading branch information
aryaemami59 committed Oct 22, 2025
commit 9500a851785beee5e19062399678a65fe4f2eb1d
3 changes: 1 addition & 2 deletions packages/toolkit/src/createAsyncThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface SerializedError {
code?: string
}

const commonProperties: Array<keyof SerializedError> = [
const commonProperties: (keyof SerializedError)[] = [
'name',
'message',
'stack',
Expand Down Expand Up @@ -644,7 +644,6 @@ export const createAsyncThunk = /* @__PURE__ */ (() => {
}

if (conditionResult === false || abortController.signal.aborted) {
// eslint-disable-next-line no-throw-literal
throw {
name: 'ConditionError',
message: 'Aborted due to condition callback returning false.',
Expand Down
17 changes: 9 additions & 8 deletions packages/toolkit/src/createSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export interface Slice<
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`.
*/
get selectors(): Id<
SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]: State }>
SliceDefinedSelectors<State, Selectors, Record<ReducerPath, State>>
>

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

/**
Expand Down Expand Up @@ -175,7 +175,7 @@ type InjectedSlice<
SliceDefinedSelectors<
State,
Selectors,
{ [K in ReducerPath]?: State | undefined }
Partial<Record<ReducerPath, State | undefined>>
>
>

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

/**
Expand Down Expand Up @@ -423,9 +423,10 @@ export type SliceCaseReducers<State> =
/**
* The type describing a slice's `selectors` option.
*/
export type SliceSelectors<State> = {
[K: string]: (sliceState: State, ...args: any[]) => any
}
export type SliceSelectors<State> = Record<
string,
(sliceState: State, ...args: any[]) => any
>

type SliceActionType<
SliceName extends string,
Expand Down Expand Up @@ -747,7 +748,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
Slice<State, CaseReducers, Name, CurrentReducerPath, Selectors>,
'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath'
> {
function selectSlice(state: { [K in CurrentReducerPath]: State }) {
function selectSlice(state: Record<CurrentReducerPath, State>) {
let sliceState = state[reducerPath]
if (typeof sliceState === 'undefined') {
if (injected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Sorted State Adapter', () => {
let state: EntityState<BookModel, string>

beforeAll(() => {
//eslint-disable-next-line
Object.defineProperty(Array.prototype, 'unwantedField', {
enumerable: true,
configurable: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import type { EntityAdapter, EntityState } from '../models'
import { createNextState } from '../..'
import { createEntityAdapter } from '../create_adapter'
import type { EntityAdapter, EntityState } from '../models'
import type { BookModel } from './fixtures/book'
import {
AClockworkOrange,
AnimalFarm,
TheGreatGatsby,
TheHobbit,
} from './fixtures/book'
import { createNextState } from '../..'

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

beforeAll(() => {
//eslint-disable-next-line
Object.defineProperty(Array.prototype, 'unwantedField', {
enumerable: true,
configurable: true,
Expand Down Expand Up @@ -293,9 +292,9 @@ describe('Unsorted State Adapter', () => {
entities: { b: { id: 'b', title: 'First' }, c: { id: 'c' } }
}
We now expect that only 'c' will be left:
{
ids: [ 'c' ],
entities: { c: { id: 'c', title: 'First' } }
{
ids: [ 'c' ],
entities: { c: { id: 'c', title: 'First' } }
}
*/
expect(ids.length).toBe(1)
Expand Down
8 changes: 4 additions & 4 deletions packages/toolkit/src/entities/unsorted_state_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function createUnsortedStateAdapter<T, Id extends EntityId>(
}

function takeNewKey(
keys: { [id: string]: Id },
keys: Record<string, Id>,
update: Update<T, Id>,
state: R,
): boolean {
Expand All @@ -129,12 +129,12 @@ export function createUnsortedStateAdapter<T, Id extends EntityId>(
}

function updateManyMutably(
updates: ReadonlyArray<Update<T, Id>>,
updates: readonly Update<T, Id>[],
state: R,
): void {
const newKeys: { [id: string]: Id } = {}
const newKeys: Record<string, Id> = {}

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

updates.forEach((update) => {
// Only apply updates to entities that currently exist
Expand Down
8 changes: 4 additions & 4 deletions packages/toolkit/src/immutableStateInvariantMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function trackProperties(
isImmutable: IsImmutableFunc,
ignorePaths: IgnorePaths = [],
obj: Record<string, any>,
path: string = '',
checkedObjects: Set<Record<string, any>> = new Set(),
path = '',
checkedObjects = new Set<Record<string, any>>(),
) {
const tracked: Partial<TrackedProperty> = { value: obj }

Expand Down Expand Up @@ -66,8 +66,8 @@ function detectMutations(
ignoredPaths: IgnorePaths = [],
trackedProperty: TrackedProperty,
obj: any,
sameParentRef: boolean = false,
path: string = '',
sameParentRef = false,
path = '',
): { wasMutated: boolean; path?: string } {
const prevObj = trackedProperty ? trackedProperty.value : undefined

Expand Down
20 changes: 10 additions & 10 deletions packages/toolkit/src/query/core/buildThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ import {
isQueryDefinition,
} from '../endpointDefinitions'
import { HandledError } from '../HandledError'
import {
NamedSchemaError,
parseWithSchema,
shouldSkip,
} from '../standardSchema'
import type { UnwrapPromise } from '../tsHelpers'
import type {
InfiniteData,
Expand Down Expand Up @@ -68,11 +73,6 @@ import {
isRejected,
isRejectedWithValue,
} from './rtkImports'
import {
parseWithSchema,
NamedSchemaError,
shouldSkip,
} from '../standardSchema'

export type BuildThunksApiEndpointQuery<
Definition extends QueryDefinition<any, any, any, any, any>,
Expand Down Expand Up @@ -391,12 +391,12 @@ export function buildThunks<
)
}

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

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

try {
let transformResponse: TransformCallback = defaultTransformResponse
const transformResponse: TransformCallback = defaultTransformResponse

const baseQueryApi = {
signal,
Expand Down Expand Up @@ -786,7 +786,7 @@ export function buildThunks<
} catch (error) {
let caughtError = error
if (caughtError instanceof HandledError) {
let transformErrorResponse = getTransformCallbackForEndpoint(
const transformErrorResponse = getTransformCallbackForEndpoint(
endpointDefinition,
'transformErrorResponse',
)
Expand Down Expand Up @@ -999,7 +999,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
const force = hasTheForce(options) && options.force
const maxAge = hasMaxAge(options) && options.ifOlderThan

const queryAction = (force: boolean = true) => {
const queryAction = (force = true) => {
const options = { forceRefetch: force, isPrefetch: true }
return (
api.endpoints[endpointName] as ApiEndpointQuery<any, any>
Expand Down
27 changes: 10 additions & 17 deletions packages/toolkit/src/query/core/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export type CoreModule =
export type ThunkWithReturnValue<T> = ThunkAction<T, any, any, UnknownAction>

export interface ApiModules<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
BaseQuery extends BaseQueryFn,
Definitions extends EndpointDefinitions,
ReducerPath extends string,
Expand Down Expand Up @@ -216,9 +215,10 @@ export interface ApiModules<
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
*/
getRunningQueriesThunk(): ThunkWithReturnValue<
Array<
QueryActionCreatorResult<any> | InfiniteQueryActionCreatorResult<any>
>
(
| QueryActionCreatorResult<any>
| InfiniteQueryActionCreatorResult<any>
)[]
>

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

/**
Expand Down Expand Up @@ -371,7 +371,7 @@ export interface ApiModules<
* ```
*/
invalidateTags: ActionCreatorWithPayload<
Array<TagDescription<TagTypes> | null | undefined>,
(TagDescription<TagTypes> | null | undefined)[],
string
>

Expand All @@ -382,12 +382,12 @@ export interface ApiModules<
*/
selectInvalidatedBy: (
state: RootState<Definitions, string, ReducerPath>,
tags: ReadonlyArray<TagDescription<TagTypes> | null | undefined>,
) => Array<{
tags: readonly (TagDescription<TagTypes> | null | undefined)[],
) => {
endpointName: string
originalArgs: any
queryCacheKey: string
}>
}[]

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

export interface ApiEndpointQuery<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Definition extends QueryDefinition<any, any, any, any, any>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Definitions extends EndpointDefinitions,
> extends BuildThunksApiEndpointQuery<Definition>,
BuildInitiateApiEndpointQuery<Definition>,
Expand All @@ -442,9 +440,7 @@ export interface ApiEndpointQuery<
}

export interface ApiEndpointInfiniteQuery<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Definition extends InfiniteQueryDefinition<any, any, any, any, any>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Definitions extends EndpointDefinitions,
> extends BuildThunksApiEndpointInfiniteQuery<Definition>,
BuildInitiateApiEndpointInfiniteQuery<Definition>,
Expand All @@ -456,11 +452,8 @@ export interface ApiEndpointInfiniteQuery<
Types: NonNullable<Definition['Types']>
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface ApiEndpointMutation<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Definition extends MutationDefinition<any, any, any, any, any>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Definitions extends EndpointDefinitions,
> extends BuildThunksApiEndpointMutation<Definition>,
BuildInitiateApiEndpointMutation<Definition>,
Expand Down
3 changes: 0 additions & 3 deletions packages/toolkit/src/query/react/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ export type ReactHooksModule = typeof reactHooksModuleName

declare module '@reduxjs/toolkit/query' {
export interface ApiModules<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
BaseQuery extends BaseQueryFn,
Definitions extends EndpointDefinitions,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ReducerPath extends string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
TagTypes extends string,
> {
[reactHooksModuleName]: {
Expand Down
5 changes: 2 additions & 3 deletions packages/toolkit/src/query/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { HandledError } from './HandledError'
* @param maxRetries - Maximum number of retries
*/
async function defaultBackoff(
attempt: number = 0,
maxRetries: number = 5,
attempt = 0,
maxRetries = 5,
signal?: AbortSignal,
) {
const attempts = Math.min(attempt, maxRetries)
Expand Down Expand Up @@ -142,7 +142,6 @@ const retryWithBackoff: BaseQueryEnhancer<
}
let retry = 0

// eslint-disable-next-line no-constant-condition
while (true) {
// Check if aborted before each attempt
failIfAborted(api.signal)
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/tests/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ beforeEach(() => {
vi.useFakeTimers()
})

const loopTimers = async (max: number = 12) => {
const loopTimers = async (max = 12) => {
let count = 0
while (count < max) {
await vi.advanceTimersByTimeAsync(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type IgnorePaths = readonly (string | RegExp)[]
*/
export function findNonSerializableValue(
value: unknown,
path: string = '',
path = '',
isSerializable: (value: unknown) => boolean = isPlain,
getEntries?: (value: unknown) => [string, any][],
ignoredPaths: IgnorePaths = [],
Expand Down
1 change: 0 additions & 1 deletion packages/toolkit/src/tests/createSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ describe('createSlice', () => {
},
},
extraReducers(builder) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
builder.addCase(second.actions.other, () => {
return 'firstOther'
})
Expand Down