Skip to content

Commit fc151de

Browse files
ci: apply automated fixes
1 parent 5d3fcb0 commit fc151de

17 files changed

Lines changed: 48 additions & 134 deletions

File tree

‎packages/react-router/src/Scripts.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ export const Scripts = () => {
7171
deepEqual,
7272
)
7373
// eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static
74-
const scripts = useStore(
75-
router.stores.matches,
76-
getScripts,
77-
deepEqual,
78-
)
74+
const scripts = useStore(router.stores.matches, getScripts, deepEqual)
7975

8076
return renderScripts(router, scripts, assetScripts)
8177
}

‎packages/react-router/src/Transitioner.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ export function Transitioner() {
1717
const [isTransitioning, setIsTransitioning] = React.useState(false)
1818
// Track pending state changes
1919
const isLoading = useStore(router.stores.isLoading, (value) => value)
20-
const hasPending = useStore(
21-
router.stores.hasPending,
22-
(value) => value,
23-
)
20+
const hasPending = useStore(router.stores.hasPending, (value) => value)
2421

2522
const previousIsLoading = usePrevious(isLoading)
2623

‎packages/router-core/src/load-matches.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ const hasForcePendingActiveMatch = (router: AnyRouter): boolean => {
5151
}
5252

5353
const resolvePreload = (inner: InnerLoadContext, matchId: string): boolean => {
54-
return !!(
55-
inner.preload && !inner.router.stores.matchStores.has(matchId)
56-
)
54+
return !!(inner.preload && !inner.router.stores.matchStores.has(matchId))
5755
}
5856

5957
/**
@@ -887,9 +885,8 @@ const loadRouteMatch = async (
887885
const previousRouteMatchId =
888886
activeAtIndex?.routeId === routeId
889887
? activeIdAtIndex
890-
: inner.router.stores.matches
891-
.get()
892-
.find((d) => d.routeId === routeId)?.id
888+
: inner.router.stores.matches.get().find((d) => d.routeId === routeId)
889+
?.id
893890
const preload = resolvePreload(inner, matchId)
894891

895892
// there is a loaderPromise, so we are in the middle of a load

‎packages/router-core/src/router.ts‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,8 +1717,7 @@ export class RouterCore<
17171717
// Determine params: reuse from state if possible, otherwise parse
17181718
const lastStateMatchId = last(this.stores.matchesId.get())
17191719
const lastStateMatch =
1720-
lastStateMatchId &&
1721-
this.stores.matchStores.get(lastStateMatchId)?.get()
1720+
lastStateMatchId && this.stores.matchStores.get(lastStateMatchId)?.get()
17221721
const canReuseParams =
17231722
lastStateMatch &&
17241723
lastStateMatch.routeId === lastRoute.id &&
@@ -2428,11 +2427,9 @@ export class RouterCore<
24282427
let hookStayingMatches: Array<AnyRouteMatch> | null = null
24292428

24302429
this.batch(() => {
2431-
const pendingMatches =
2432-
this.stores.pendingMatches.get()
2430+
const pendingMatches = this.stores.pendingMatches.get()
24332431
const mountPending = pendingMatches.length
2434-
const currentMatches =
2435-
this.stores.matches.get()
2432+
const currentMatches = this.stores.matches.get()
24362433

24372434
exitingMatches = mountPending
24382435
? currentMatches.filter(
@@ -2527,9 +2524,7 @@ export class RouterCore<
25272524
? redirect.status
25282525
: notFound
25292526
? 404
2530-
: this.stores.matches
2531-
.get()
2532-
.some((d) => d.status === 'error')
2527+
: this.stores.matches.get().some((d) => d.status === 'error')
25332528
? 500
25342529
: 200
25352530

@@ -2563,9 +2558,7 @@ export class RouterCore<
25632558
let newStatusCode: number | undefined = undefined
25642559
if (this.hasNotFoundMatch()) {
25652560
newStatusCode = 404
2566-
} else if (
2567-
this.stores.matches.get().some((d) => d.status === 'error')
2568-
) {
2561+
} else if (this.stores.matches.get().some((d) => d.status === 'error')) {
25692562
newStatusCode = 500
25702563
}
25712564
if (newStatusCode !== undefined) {
@@ -2698,15 +2691,9 @@ export class RouterCore<
26982691
}
26992692

27002693
this.batch(() => {
2701-
this.stores.setMatches(
2702-
this.stores.matches.get().map(invalidate),
2703-
)
2704-
this.stores.setCached(
2705-
this.stores.cachedMatches.get().map(invalidate),
2706-
)
2707-
this.stores.setPending(
2708-
this.stores.pendingMatches.get().map(invalidate),
2709-
)
2694+
this.stores.setMatches(this.stores.matches.get().map(invalidate))
2695+
this.stores.setCached(this.stores.cachedMatches.get().map(invalidate))
2696+
this.stores.setPending(this.stores.pendingMatches.get().map(invalidate))
27102697
})
27112698

27122699
this.shouldViewTransition = false

‎packages/router-core/tests/granular-stores.test.ts‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,12 @@ describe('granular stores', () => {
201201

202202
const postsStore = router.stores.getRouteMatchStore('/posts/$postId')
203203

204-
expect(router.stores.getRouteMatchStore('/posts/$postId')).toBe(
205-
postsStore,
206-
)
204+
expect(router.stores.getRouteMatchStore('/posts/$postId')).toBe(postsStore)
207205
expect(postsStore.get()?.routeId).toBe('/posts/$postId')
208206

209207
await router.navigate({ to: '/about' })
210208

211-
expect(router.stores.getRouteMatchStore('/posts/$postId')).toBe(
212-
postsStore,
213-
)
209+
expect(router.stores.getRouteMatchStore('/posts/$postId')).toBe(postsStore)
214210
expect(postsStore.get()).toBeUndefined()
215211
})
216212

@@ -290,9 +286,7 @@ describe('granular stores', () => {
290286
const pendingStore = router.stores.pendingMatchStores.get(activeLeaf.id)
291287

292288
expect(pendingStore).toBeDefined()
293-
expect(router.stores.matchStores.get(activeLeaf.id)).toBe(
294-
activeStore,
295-
)
289+
expect(router.stores.matchStores.get(activeLeaf.id)).toBe(activeStore)
296290

297291
if (!pendingStore) {
298292
throw new Error('Expected pending leaf store to exist')
@@ -343,19 +337,17 @@ describe('granular stores', () => {
343337
),
344338
)
345339

346-
expect(
347-
router.stores.matchStores.get(duplicatedId)?.get().status,
348-
).toBe('error')
340+
expect(router.stores.matchStores.get(duplicatedId)?.get().status).toBe(
341+
'error',
342+
)
349343
expect(
350344
router.stores.getRouteMatchStore(activeLeaf.routeId).get()?.status,
351345
).toBe('error')
352346
// Pending pool has its own store for this id
353347
expect(
354348
router.stores.pendingMatchStores.get(duplicatedId)?.get().status,
355349
).toBe('pending')
356-
expect(router.stores.pendingMatches.get()[0]?.status).toBe(
357-
'pending',
358-
)
350+
expect(router.stores.pendingMatches.get()[0]?.status).toBe('pending')
359351
expect(router.stores.cachedMatches.get()[0]?.status).toBe('success')
360352
expect(router.getMatch(duplicatedId)?.status).toBe('success')
361353
})

‎packages/router-core/tests/load.test.ts‎

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,14 @@ describe('beforeLoad skip or exec', () => {
203203
})
204204
await router.preloadRoute({ to: '/foo' })
205205
expect(
206-
router.stores.cachedMatches
207-
.get()
208-
.some((d) => d.status === 'redirected'),
206+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
209207
).toBe(false)
210208
await sleep(10)
211209
await router.navigate({ to: '/foo' })
212210

213211
expect(router.state.location.pathname).toBe('/foo')
214212
expect(
215-
router.stores.cachedMatches
216-
.get()
217-
.some((d) => d.status === 'redirected'),
213+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
218214
).toBe(false)
219215
expect(beforeLoad).toHaveBeenCalledTimes(2)
220216
})
@@ -230,17 +226,13 @@ describe('beforeLoad skip or exec', () => {
230226
router.preloadRoute({ to: '/foo' })
231227
await Promise.resolve()
232228
expect(
233-
router.stores.cachedMatches
234-
.get()
235-
.some((d) => d.status === 'redirected'),
229+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
236230
).toBe(false)
237231
await router.navigate({ to: '/foo' })
238232

239233
expect(router.state.location.pathname).toBe('/foo')
240234
expect(
241-
router.stores.cachedMatches
242-
.get()
243-
.some((d) => d.status === 'redirected'),
235+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
244236
).toBe(false)
245237
expect(beforeLoad).toHaveBeenCalledTimes(2)
246238
})
@@ -456,18 +448,14 @@ describe('loader skip or exec', () => {
456448
})
457449
await router.preloadRoute({ to: '/foo' })
458450
expect(
459-
router.stores.cachedMatches
460-
.get()
461-
.some((d) => d.status === 'redirected'),
451+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
462452
).toBe(false)
463453
await sleep(10)
464454
await router.navigate({ to: '/foo' })
465455

466456
expect(router.state.location.pathname).toBe('/foo')
467457
expect(
468-
router.stores.cachedMatches
469-
.get()
470-
.some((d) => d.status === 'redirected'),
458+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
471459
).toBe(false)
472460
expect(loader).toHaveBeenCalledTimes(2)
473461
})
@@ -483,17 +471,13 @@ describe('loader skip or exec', () => {
483471
router.preloadRoute({ to: '/foo' })
484472
await Promise.resolve()
485473
expect(
486-
router.stores.cachedMatches
487-
.get()
488-
.some((d) => d.status === 'redirected'),
474+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
489475
).toBe(false)
490476
await router.navigate({ to: '/foo' })
491477

492478
expect(router.state.location.pathname).toBe('/bar')
493479
expect(
494-
router.stores.cachedMatches
495-
.get()
496-
.some((d) => d.status === 'redirected'),
480+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
497481
).toBe(false)
498482
expect(loader).toHaveBeenCalledTimes(1)
499483
})
@@ -513,14 +497,10 @@ describe('loader skip or exec', () => {
513497
}))
514498

515499
expect(
516-
router.stores.cachedMatches
517-
.get()
518-
.some((d) => d.id === '/foo/foo'),
500+
router.stores.cachedMatches.get().some((d) => d.id === '/foo/foo'),
519501
).toBe(false)
520502
expect(
521-
router.stores.cachedMatches
522-
.get()
523-
.some((d) => d.status === 'redirected'),
503+
router.stores.cachedMatches.get().some((d) => d.status === 'redirected'),
524504
).toBe(false)
525505
})
526506

@@ -648,9 +628,7 @@ describe('stale loader reload triggers', () => {
648628
id: string,
649629
) =>
650630
router.state.matches.find((match) => match.id === id) ??
651-
router.stores.pendingMatches
652-
.get()
653-
.find((match) => match.id === id) ??
631+
router.stores.pendingMatches.get().find((match) => match.id === id) ??
654632
router.stores.cachedMatches.get().find((match) => match.id === id)
655633

656634
const hasActiveMatch = (
@@ -662,9 +640,7 @@ describe('stale loader reload triggers', () => {
662640
router: RouterCore<any, any, any, any, any>,
663641
id: string,
664642
) =>
665-
router.stores.pendingMatches
666-
.get()
667-
.some((match) => match.id === id) ?? false
643+
router.stores.pendingMatches.get().some((match) => match.id === id) ?? false
668644

669645
const setup = ({
670646
loader,

‎packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,12 @@ export const BaseTanStackRouterDevtoolsPanel =
281281
let cachedMatches: Accessor<Array<AnyRouteMatch>>
282282
// subscribable implementation
283283
if ('subscribe' in router().stores.pendingMatches) {
284-
const [_pendingMatches, setPending] = createSignal<
285-
Array<AnyRouteMatch>
286-
>([])
284+
const [_pendingMatches, setPending] = createSignal<Array<AnyRouteMatch>>(
285+
[],
286+
)
287287
pendingMatches = _pendingMatches
288288

289-
const [_cachedMatches, setCached] = createSignal<
290-
Array<AnyRouteMatch>
291-
>([])
289+
const [_cachedMatches, setCached] = createSignal<Array<AnyRouteMatch>>([])
292290
cachedMatches = _cachedMatches
293291

294292
type Subscribe = (fn: () => void) => { unsubscribe: () => void }

‎packages/router-plugin/src/core/route-hmr-statement.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ type AnyRouterWithPrivateMaps = AnyRouter & {
3030
string,
3131
Pick<RouterWritableStore<AnyRouteMatch>, 'set'>
3232
>
33-
matchStores: Map<
34-
string,
35-
Pick<RouterWritableStore<AnyRouteMatch>, 'set'>
36-
>
33+
matchStores: Map<string, Pick<RouterWritableStore<AnyRouteMatch>, 'set'>>
3734
}
3835
}
3936

‎packages/solid-router/src/Matches.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ function MatchesInner() {
6565
const matchId = () => router.stores.firstId.get()
6666
const routeId = () => (matchId() ? rootRouteId : undefined)
6767
const match = () =>
68-
routeId()
69-
? router.stores.getRouteMatchStore(rootRouteId).get()
70-
: undefined
68+
routeId() ? router.stores.getRouteMatchStore(rootRouteId).get() : undefined
7169
const hasPendingMatch = () =>
7270
routeId()
7371
? Boolean(router.stores.pendingRouteIds.get()[rootRouteId])

‎packages/solid-router/src/Scripts.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import type { RouterManagedTag } from '@tanstack/router-core'
66
export const Scripts = () => {
77
const router = useRouter()
88
const nonce = router.options.ssr?.nonce
9-
const activeMatches = Solid.createMemo(() =>
10-
router.stores.matches.get(),
11-
)
9+
const activeMatches = Solid.createMemo(() => router.stores.matches.get())
1210
const assetScripts = Solid.createMemo(() => {
1311
const assetScripts: Array<RouterManagedTag> = []
1412
const manifest = router.ssr?.manifest

0 commit comments

Comments
 (0)