Skip to content

Commit 367f4bd

Browse files
committed
Change all let variables to const to comply with prefer-const rule
1 parent c54dd95 commit 367f4bd

25 files changed

+144
-157
lines changed

packages/toolkit/src/configureStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function configureStore<
216216
throw new Error('`enhancers` field must be a callback')
217217
}
218218

219-
let storeEnhancers =
219+
const storeEnhancers =
220220
typeof enhancers === 'function'
221221
? enhancers(getDefaultEnhancers)
222222
: getDefaultEnhancers()

packages/toolkit/src/createAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export function createAction<
260260
export function createAction(type: string, prepareAction?: Function): any {
261261
function actionCreator(...args: any[]) {
262262
if (prepareAction) {
263-
let prepared = prepareAction(...args)
263+
const prepared = prepareAction(...args)
264264
if (!prepared) {
265265
throw new Error('prepareAction did not return an object')
266266
}

packages/toolkit/src/createReducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function createReducer<S extends NotFunction<any>>(
149149
}
150150
}
151151

152-
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] =
152+
const [actionsMap, finalActionMatchers, finalDefaultCaseReducer] =
153153
executeReducerBuilderCallback(mapOrBuilderCallback)
154154

155155
// Ensure the initial state gets frozen either way (if draftable)

packages/toolkit/src/createSlice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,13 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
707707
}
708708

709709
return createReducer(options.initialState, (builder) => {
710-
for (let key in finalCaseReducers) {
710+
for (const key in finalCaseReducers) {
711711
builder.addCase(key, finalCaseReducers[key] as CaseReducer<any>)
712712
}
713-
for (let sM of context.sliceMatchers) {
713+
for (const sM of context.sliceMatchers) {
714714
builder.addMatcher(sM.matcher, sM.reducer)
715715
}
716-
for (let m of actionMatchers) {
716+
for (const m of actionMatchers) {
717717
builder.addMatcher(m.matcher, m.reducer)
718718
}
719719
if (defaultCaseReducer) {

packages/toolkit/src/entities/sorted_state_adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function findInsertIndex<T>(
2424
let lowIndex = 0
2525
let highIndex = sortedItems.length
2626
while (lowIndex < highIndex) {
27-
let middleIndex = (lowIndex + highIndex) >>> 1
27+
const middleIndex = (lowIndex + highIndex) >>> 1
2828
const currentItem = sortedItems[middleIndex]
2929
const res = comparisonFunction(item, currentItem)
3030
if (res >= 0) {
@@ -119,7 +119,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
119119
let appliedUpdates = false
120120
let replacedIds = false
121121

122-
for (let update of updates) {
122+
for (const update of updates) {
123123
const entity: T | undefined = (state.entities as Record<Id, T>)[update.id]
124124
if (!entity) {
125125
continue

packages/toolkit/src/getDefaultEnhancers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const buildGetDefaultEnhancers = <M extends Middlewares<any>>(
1919
function getDefaultEnhancers(options) {
2020
const { autoBatch = true } = options ?? {}
2121

22-
let enhancerArray = new Tuple<StoreEnhancer[]>(middlewareEnhancer)
22+
const enhancerArray = new Tuple<StoreEnhancer[]>(middlewareEnhancer)
2323
if (autoBatch) {
2424
enhancerArray.push(
2525
autoBatchEnhancer(

packages/toolkit/src/getDefaultMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const buildGetDefaultMiddleware = <S = any>(): GetDefaultMiddleware<S> =>
5959
actionCreatorCheck = true,
6060
} = options ?? {}
6161

62-
let middlewareArray = new Tuple<Middleware[]>()
62+
const middlewareArray = new Tuple<Middleware[]>()
6363

6464
if (thunk) {
6565
if (isBoolean(thunk)) {

packages/toolkit/src/immutableStateInvariantMiddleware.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ function detectMutations(
8383

8484
// Gather all keys from prev (tracked) and after objs
8585
const keysToDetect: Record<string, boolean> = {}
86-
for (let key in trackedProperty.children) {
86+
for (const key in trackedProperty.children) {
8787
keysToDetect[key] = true
8888
}
89-
for (let key in obj) {
89+
for (const key in obj) {
9090
keysToDetect[key] = true
9191
}
9292

9393
const hasIgnoredPaths = ignoredPaths.length > 0
9494

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

9898
if (hasIgnoredPaths) {
@@ -176,7 +176,7 @@ export function createImmutableStateInvariantMiddleware(
176176
serializer?: EntryProcessor,
177177
decycler?: EntryProcessor,
178178
): EntryProcessor {
179-
let stack: any[] = [],
179+
const stack: any[] = [],
180180
keys: any[] = []
181181

182182
if (!decycler)
@@ -189,7 +189,7 @@ export function createImmutableStateInvariantMiddleware(
189189

190190
return function (this: any, key: string, value: any) {
191191
if (stack.length > 0) {
192-
var thisPos = stack.indexOf(this)
192+
const thisPos = stack.indexOf(this)
193193
~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
194194
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
195195
if (~stack.indexOf(value)) value = decycler!.call(this, key, value)
@@ -199,7 +199,7 @@ export function createImmutableStateInvariantMiddleware(
199199
}
200200
}
201201

202-
let {
202+
const {
203203
isImmutable = isImmutableDefault,
204204
ignoredPaths,
205205
warnAfter = 32,

packages/toolkit/src/listenerMiddleware/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const createTakePattern = <S>(
149149

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

194194
const getListenerEntryPropsFrom = (options: FallbackAddListenerOptions) => {
195-
let { type, actionCreator, matcher, predicate, effect } = options
195+
let { type, predicate } = options
196+
const { actionCreator, matcher, effect } = options
196197

197198
if (type) {
198199
predicate = createAction(type).match

packages/toolkit/src/listenerMiddleware/tests/effectScenarios.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ describe('Saga-style Effects Scenarios', () => {
3232
})
3333
const { increment, decrement, incrementByAmount } = counterSlice.actions
3434

35-
let { reducer } = counterSlice
35+
const { reducer } = counterSlice
3636
let listenerMiddleware = createListenerMiddleware<CounterState>()
37-
let { middleware, startListening, stopListening } = listenerMiddleware
37+
let { middleware, startListening } = listenerMiddleware
3838

3939
let store = configureStore({
4040
reducer,

0 commit comments

Comments
 (0)