Skip to content

Commit 670c376

Browse files
committed
Fix @typescript-eslint/no-unused-expressions related issues
1 parent 9295299 commit 670c376

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/toolkit/src/immutableStateInvariantMiddleware.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Middleware } from 'redux'
22
import type { IgnorePaths } from './serializableStateInvariantMiddleware'
3+
import type { AnyObject } from './tsHelpers'
34
import { getTimeMeasureUtils } from './utils'
45

56
type EntryProcessor = (key: string, value: any) => any
@@ -190,8 +191,16 @@ export function createImmutableStateInvariantMiddleware(
190191
return function (this: any, key: string, value: any) {
191192
if (stack.length > 0) {
192193
const thisPos = stack.indexOf(this)
193-
~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
194-
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
194+
if (~thisPos) {
195+
stack.splice(thisPos + 1)
196+
} else {
197+
stack.push(this)
198+
}
199+
if (~thisPos) {
200+
keys.splice(thisPos, Infinity, key)
201+
} else {
202+
keys.push(key)
203+
}
195204
if (~stack.indexOf(value)) value = decycler!.call(this, key, value)
196205
} else stack.push(value)
197206

packages/toolkit/src/query/tests/cacheCollection.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ test(`query: handles large keepUnuseDataFor values over 32-bit ms`, async () =>
8787
expect(onCleanup).not.toHaveBeenCalled()
8888

8989
// _Should_ be called _wayyyy_ in the future (like 24.8 days from now)
90-
vi.advanceTimersByTime(THIRTY_TWO_BIT_MAX_TIMER_SECONDS * 1000),
91-
expect(onCleanup).toHaveBeenCalled()
90+
vi.advanceTimersByTime(THIRTY_TWO_BIT_MAX_TIMER_SECONDS * 1000)
91+
expect(onCleanup).toHaveBeenCalled()
9292
})
9393

9494
describe(`query: await cleanup, keepUnusedDataFor set`, () => {

packages/toolkit/src/tests/createDraftSafeSelector.withTypes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ describe(createDraftSafeSelector.withTypes, () => {
4444
(todos) => todos.map(({ id }) => id),
4545
)
4646

47-
expect(selectTodoIds(rootState)).to.be.an('array').that.is.not.empty
47+
expect(selectTodoIds(rootState)).to.be.an('array').with.lengthOf(2)
4848
})
4949
})

0 commit comments

Comments
 (0)