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
Change all let variables to const to comply with prefer-const rule
  • Loading branch information
aryaemami59 committed Oct 22, 2025
commit a69e82c09a0dbf42d6cebb26821b8150007d3668
2 changes: 1 addition & 1 deletion packages/toolkit/src/configureStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function configureStore<
throw new Error('`enhancers` field must be a callback')
}

let storeEnhancers =
const storeEnhancers =
typeof enhancers === 'function'
? enhancers(getDefaultEnhancers)
: getDefaultEnhancers()
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/createAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export function createAction<
export function createAction(type: string, prepareAction?: Function): any {
function actionCreator(...args: any[]) {
if (prepareAction) {
let prepared = prepareAction(...args)
const prepared = prepareAction(...args)
if (!prepared) {
throw new Error('prepareAction did not return an object')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/createReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function createReducer<S extends NotFunction<any>>(
}
}

let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] =
const [actionsMap, finalActionMatchers, finalDefaultCaseReducer] =
executeReducerBuilderCallback(mapOrBuilderCallback)

// Ensure the initial state gets frozen either way (if draftable)
Expand Down
6 changes: 3 additions & 3 deletions packages/toolkit/src/createSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,13 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
}

return createReducer(options.initialState, (builder) => {
for (let key in finalCaseReducers) {
for (const key in finalCaseReducers) {
builder.addCase(key, finalCaseReducers[key] as CaseReducer<any>)
}
for (let sM of context.sliceMatchers) {
for (const sM of context.sliceMatchers) {
builder.addMatcher(sM.matcher, sM.reducer)
}
for (let m of actionMatchers) {
for (const m of actionMatchers) {
builder.addMatcher(m.matcher, m.reducer)
}
if (defaultCaseReducer) {
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/entities/sorted_state_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function findInsertIndex<T>(
let lowIndex = 0
let highIndex = sortedItems.length
while (lowIndex < highIndex) {
let middleIndex = (lowIndex + highIndex) >>> 1
const middleIndex = (lowIndex + highIndex) >>> 1
const currentItem = sortedItems[middleIndex]
const res = comparisonFunction(item, currentItem)
if (res >= 0) {
Expand Down Expand Up @@ -127,7 +127,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
let appliedUpdates = false
let replacedIds = false

for (let update of updates) {
for (const update of updates) {
const entity: T | undefined = (state.entities as Record<Id, T>)[update.id]
if (!entity) {
continue
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/getDefaultEnhancers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const buildGetDefaultEnhancers = <M extends Middlewares<any>>(
function getDefaultEnhancers(options) {
const { autoBatch = true } = options ?? {}

let enhancerArray = new Tuple<StoreEnhancer[]>(middlewareEnhancer)
const enhancerArray = new Tuple<StoreEnhancer[]>(middlewareEnhancer)
if (autoBatch) {
enhancerArray.push(
autoBatchEnhancer(
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/getDefaultMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const buildGetDefaultMiddleware = <S = any>(): GetDefaultMiddleware<S> =>
actionCreatorCheck = true,
} = options ?? {}

let middlewareArray = new Tuple<Middleware[]>()
const middlewareArray = new Tuple<Middleware[]>()

if (thunk) {
if (isBoolean(thunk)) {
Expand Down
12 changes: 6 additions & 6 deletions packages/toolkit/src/immutableStateInvariantMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ function detectMutations(

// Gather all keys from prev (tracked) and after objs
const keysToDetect: Record<string, boolean> = {}
for (let key in trackedProperty.children) {
for (const key in trackedProperty.children) {
keysToDetect[key] = true
}
for (let key in obj) {
for (const key in obj) {
keysToDetect[key] = true
}

const hasIgnoredPaths = ignoredPaths.length > 0

for (let key in keysToDetect) {
for (const key in keysToDetect) {
const nestedPath = path ? path + '.' + key : key

if (hasIgnoredPaths) {
Expand Down Expand Up @@ -176,7 +176,7 @@ export function createImmutableStateInvariantMiddleware(
serializer?: EntryProcessor,
decycler?: EntryProcessor,
): EntryProcessor {
let stack: any[] = [],
const stack: any[] = [],
keys: any[] = []

if (!decycler)
Expand All @@ -189,7 +189,7 @@ export function createImmutableStateInvariantMiddleware(

return function (this: any, key: string, value: any) {
if (stack.length > 0) {
var thisPos = stack.indexOf(this)
const thisPos = stack.indexOf(this)
~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
if (~stack.indexOf(value)) value = decycler!.call(this, key, value)
Expand All @@ -199,7 +199,7 @@ export function createImmutableStateInvariantMiddleware(
}
}

let {
const {
isImmutable = isImmutableDefault,
ignoredPaths,
warnAfter = 32,
Expand Down
5 changes: 3 additions & 2 deletions packages/toolkit/src/listenerMiddleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const createTakePattern = <S>(

const tuplePromise = new Promise<[Action, S, S]>((resolve, reject) => {
// Inside the Promise, we synchronously add the listener.
let stopListening = startListening({
const stopListening = startListening({
predicate: predicate as any,
effect: (action, listenerApi): void => {
// One-shot listener that cleans up as soon as the predicate passes
Expand Down Expand Up @@ -192,7 +192,8 @@ const createTakePattern = <S>(
}

const getListenerEntryPropsFrom = (options: FallbackAddListenerOptions) => {
let { type, actionCreator, matcher, predicate, effect } = options
let { type, predicate } = options
const { actionCreator, matcher, effect } = options

if (type) {
predicate = createAction(type).match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ describe('Saga-style Effects Scenarios', () => {
})
const { increment, decrement, incrementByAmount } = counterSlice.actions

let { reducer } = counterSlice
const { reducer } = counterSlice
let listenerMiddleware = createListenerMiddleware<CounterState>()
let { middleware, startListening, stopListening } = listenerMiddleware
let { middleware, startListening } = listenerMiddleware

let store = configureStore({
reducer,
Expand Down
16 changes: 8 additions & 8 deletions packages/toolkit/src/listenerMiddleware/tests/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe('fork', () => {
expected: { status: 'ok', value: 5 },
},
])('$desc', async ({ executor, expected, cancelAfterMs }) => {
let deferredResult = deferred()
const deferredResult = deferred()
let forkedTask: any = {}

startListening({
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('fork', () => {

describe('forkAPI', () => {
test('forkApi.delay rejects as soon as the task is cancelled', async () => {
let deferredResult = deferred()
const deferredResult = deferred()

startListening({
actionCreator: increment,
Expand All @@ -322,7 +322,7 @@ describe('fork', () => {
})

test('forkApi.delay rejects as soon as the parent listener is cancelled', async () => {
let deferredResult = deferred()
const deferredResult = deferred()

startListening({
actionCreator: increment,
Expand Down Expand Up @@ -374,7 +374,7 @@ describe('fork', () => {
])(
'signal is $expectedAbortReason when autoJoin: $autoJoin, cancelListener: $cancelListener',
async ({ autoJoin, cancelListener, expectedAbortReason }) => {
let deferredResult = deferred()
const deferredResult = deferred()

const unsubscribe = startListening({
actionCreator: increment,
Expand Down Expand Up @@ -406,8 +406,8 @@ describe('fork', () => {
)

test('fork.delay does not trigger unhandledRejections for completed or cancelled tasks', async () => {
let deferredCompletedEvt = deferred()
let deferredCancelledEvt = deferred()
const deferredCompletedEvt = deferred()
const deferredCancelledEvt = deferred()

// Unfortunately we cannot test declaratively unhandleRejections in jest: https://github.com/facebook/jest/issues/5620
// This test just fails if an `unhandledRejection` occurs.
Expand Down Expand Up @@ -453,7 +453,7 @@ describe('fork', () => {
})

test('forkApi.pause rejects if task is cancelled', async () => {
let deferredResult = deferred()
const deferredResult = deferred()
startListening({
actionCreator: increment,
effect: async (_, listenerApi) => {
Expand All @@ -478,7 +478,7 @@ describe('fork', () => {
})

test('forkApi.pause rejects as soon as the parent listener is cancelled', async () => {
let deferredResult = deferred()
const deferredResult = deferred()

startListening({
actionCreator: increment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const { increment, decrement, incrementByAmount } = counterSlice.actions

describe('Saga-style Effects Scenarios', () => {
let listenerMiddleware = createListenerMiddleware<CounterState>()
let { middleware, startListening, stopListening } = listenerMiddleware
let { middleware, startListening } = listenerMiddleware

let store = configureStore({
reducer: counterSlice.reducer,
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Saga-style Effects Scenarios', () => {
// function by wrapping an event emitter so that every call returns a
// promise that is resolved the next time an event is emitted.
// This is the tiniest event emitter I could find to copy-paste in here.
let createNanoEvents = () => ({
const createNanoEvents = () => ({
events: {} as Record<string, any>,
emit(event: string, ...args: any[]) {
;(this.events[event] || []).forEach((i: any) => i(...args))
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/nanoid.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Borrowed from https://github.com/ai/nanoid/blob/3.0.2/non-secure/index.js
// This alphabet uses `A-Za-z0-9_-` symbols. A genetic algorithm helped
// optimize the gzip compression for this alphabet.
let urlAlphabet =
const urlAlphabet =
'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'

/**
*
* @public
*/
export let nanoid = (size = 21) => {
export const nanoid = (size = 21) => {
let id = ''
// A compact alternative for `for (var i = 0; i < step; i++)`.
let i = size
Expand Down
10 changes: 3 additions & 7 deletions packages/toolkit/src/query/core/buildMiddleware/polling.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import type {
QueryCacheKey,
QuerySubstateIdentifier,
Subscribers,
SubscribersInternal,
} from '../apiState'
import { QueryStatus } from '../apiState'
import type {
QueryStateMeta,
SubMiddlewareApi,
TimeoutId,
InternalHandlerBuilder,
ApiMiddlewareInternalHandler,
InternalMiddlewareState,
InternalHandlerBuilder,
SubMiddlewareApi,
} from './types'

export const buildPollingHandler: InternalHandlerBuilder = ({
Expand Down Expand Up @@ -182,7 +178,7 @@ export const buildPollingHandler: InternalHandlerBuilder = ({
let lowestPollingInterval = Number.POSITIVE_INFINITY

for (const entry of subscribers.values()) {
if (!!entry.pollingInterval) {
if (entry.pollingInterval) {
lowestPollingInterval = Math.min(
entry.pollingInterval!,
lowestPollingInterval,
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/core/buildSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export function buildSelectors<
continue
}

let invalidateSubscriptions =
const invalidateSubscriptions =
(tag.id !== undefined
? // id given: invalidate all queries that provide this type & id
provided[tag.id]
Expand Down
21 changes: 12 additions & 9 deletions packages/toolkit/src/query/core/buildSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,18 @@ export function buildSlice({
// We're already inside an Immer-powered reducer, and the user could just mutate `substate.data`
// themselves inside of `merge()`. But, they might also want to return a new value.
// Try to let Immer figure that part out, save the result, and assign it to `substate.data`.
let newData = createNextState(substate.data, (draftSubstateData) => {
// As usual with Immer, you can mutate _or_ return inside here, but not both
return merge(draftSubstateData, payload, {
arg: arg.originalArgs,
baseQueryMeta,
fulfilledTimeStamp,
requestId,
})
})
const newData = createNextState(
substate.data,
(draftSubstateData) => {
// As usual with Immer, you can mutate _or_ return inside here, but not both
return merge(draftSubstateData, payload, {
arg: arg.originalArgs,
baseQueryMeta,
fulfilledTimeStamp,
requestId,
})
},
)
substate.data = newData
} else {
// Presumably a fresh request. Just cache the response data.
Expand Down
Loading