Skip to content

Commit 452f876

Browse files
ci: apply automated fixes
1 parent 8feb3c0 commit 452f876

File tree

8 files changed

+30
-43
lines changed

8 files changed

+30
-43
lines changed

packages/react-router/src/link.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import { useActiveLocation } from './useActiveLocation'
1111
import { useRouterState } from './useRouterState'
1212
import { useRouter } from './useRouter'
1313

14-
import {
15-
useForwardedRef,
16-
useIntersectionObserver,
17-
} from './utils'
14+
import { useForwardedRef, useIntersectionObserver } from './utils'
1815

1916
import type {
2017
AnyRouter,
@@ -102,13 +99,13 @@ export function useLinkProps<
10299
structuralSharing: true as any,
103100
})
104101

105-
const {getFromPath} = useActiveLocation()
102+
const { getFromPath } = useActiveLocation()
106103

107104
const from = getFromPath(options.from)
108105

109106
const _options = React.useMemo(
110107
() => {
111-
return { ...options, from }
108+
return { ...options, from }
112109
},
113110
// eslint-disable-next-line react-hooks/exhaustive-deps
114111
[

packages/react-router/src/useActiveLocation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { useMatch } from './useMatch'
44
import { useRouterState } from './useRouterState'
55
import type { AnyRouteMatch } from '@tanstack/router-core'
66

7-
export type UseLocationResult = {activeLocationMatch: AnyRouteMatch | undefined, getFromPath: (from?: string) => string}
7+
export type UseLocationResult = {
8+
activeLocationMatch: AnyRouteMatch | undefined
9+
getFromPath: (from?: string) => string
10+
}
811

912
export const useActiveLocation = (): UseLocationResult => {
1013
const router = useRouter()

packages/react-router/src/useNavigate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function useNavigate<
2121

2222
return React.useCallback(
2323
(options: NavigateOptions) => {
24-
const from = getFromPath(options.from ?? _defaultOpts?.from)
24+
const from = getFromPath(options.from ?? _defaultOpts?.from)
2525

2626
return router.navigate({
2727
...options,

packages/react-router/tests/link.test.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6057,11 +6057,7 @@ describe('when on /posts/$postId and navigating to ../ with default `from` /post
60576057
return (
60586058
<>
60596059
<h1>Posts</h1>
6060-
{
6061-
navigateVia === 'Route'
6062-
? <LinkViaRoute />
6063-
: <LinkViaRouteApi />
6064-
}
6060+
{navigateVia === 'Route' ? <LinkViaRoute /> : <LinkViaRouteApi />}
60656061
<Outlet />
60666062
</>
60676063
)

packages/react-router/tests/useNavigate.test.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,9 +1573,7 @@ test.each([true, false])(
15731573

15741574
fireEvent.click(postsButton)
15751575

1576-
expect(
1577-
await screen.findByTestId('posts-index-heading'),
1578-
).toBeInTheDocument()
1576+
expect(await screen.findByTestId('posts-index-heading')).toBeInTheDocument()
15791577
expect(window.location.pathname).toEqual(`/posts${tail}`)
15801578

15811579
const firstPostButton = await screen.findByTestId('first-post-btn')
@@ -1741,9 +1739,7 @@ test.each([true, false])(
17411739

17421740
fireEvent.click(postsButton)
17431741

1744-
expect(
1745-
await screen.findByTestId('posts-index-heading'),
1746-
).toBeInTheDocument()
1742+
expect(await screen.findByTestId('posts-index-heading')).toBeInTheDocument()
17471743

17481744
const post1Button = await screen.findByTestId('first-post-btn')
17491745

@@ -1873,7 +1869,7 @@ test.each([true, false])(
18731869

18741870
expect(router.state.location.pathname).toBe(`/`)
18751871
expect(router.state.location.search).toEqual({})
1876-
}
1872+
},
18771873
)
18781874

18791875
test.each([true, false])(
@@ -2058,9 +2054,7 @@ test.each([true, false])(
20582054

20592055
fireEvent.click(postsButton)
20602056

2061-
expect(
2062-
await screen.findByTestId('posts-index-heading'),
2063-
).toBeInTheDocument()
2057+
expect(await screen.findByTestId('posts-index-heading')).toBeInTheDocument()
20642058
expect(window.location.pathname).toEqual(`/posts${tail}`)
20652059

20662060
const firstPostButton = await screen.findByTestId('first-post-btn')
@@ -2095,18 +2089,14 @@ test.each([true, false])(
20952089

20962090
fireEvent.click(postNotesButton)
20972091

2098-
expect(
2099-
await screen.findByTestId('post-notes-heading'),
2100-
).toBeInTheDocument()
2092+
expect(await screen.findByTestId('post-notes-heading')).toBeInTheDocument()
21012093
expect(window.location.pathname).toEqual(`/posts/1/notes${tail}`)
21022094

21032095
const toPostsIndexButton = await screen.findByTestId('to-posts-index-btn')
21042096

21052097
fireEvent.click(toPostsIndexButton)
21062098

2107-
expect(
2108-
await screen.findByTestId('posts-index-heading'),
2109-
).toBeInTheDocument()
2099+
expect(await screen.findByTestId('posts-index-heading')).toBeInTheDocument()
21102100
expect(screen.queryByTestId('post-notes-heading')).not.toBeInTheDocument()
21112101
expect(
21122102
screen.queryByTestId('post-detail-index-heading'),
@@ -2357,9 +2347,7 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
23572347
Link to .. from /param/foo/a
23582348
</button>
23592349
<button
2360-
onClick={() =>
2361-
navigate({ to: '..' })
2362-
}
2350+
onClick={() => navigate({ to: '..' })}
23632351
data-testid={'link-to-previous'}
23642352
>
23652353
Link to .. from current active route
@@ -2533,7 +2521,6 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
25332521
expect(window.location.pathname).toBe(`${basepath}/param/foo/a`)
25342522
})
25352523

2536-
25372524
test('should navigate to same route with different params', async () => {
25382525
const router = setupRouter()
25392526

packages/solid-router/src/link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function useLinkProps<
141141
// })
142142

143143
const { getFromPath } = useActiveLocation()
144-
const from = getFromPath(options.from);
144+
const from = getFromPath(options.from)
145145

146146
const _options = () => {
147147
return {

packages/solid-router/src/useActiveLocation.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { last } from '@tanstack/router-core'
2-
import { createMemo } from 'solid-js'
2+
import { createMemo } from 'solid-js'
33
import { useRouterState } from './useRouterState'
44
import { useMatch } from './useMatch'
55
import { useRouter } from './useRouter'
6-
import type {Accessor} from 'solid-js';
7-
import type { AnyRouteMatch} from '@tanstack/router-core'
6+
import type { Accessor } from 'solid-js'
7+
import type { AnyRouteMatch } from '@tanstack/router-core'
88

9-
export type UseActiveLocationResult = { activeLocationMatch: Accessor<AnyRouteMatch | undefined>, getFromPath: (from?: string) => Accessor<string> }
9+
export type UseActiveLocationResult = {
10+
activeLocationMatch: Accessor<AnyRouteMatch | undefined>
11+
getFromPath: (from?: string) => Accessor<string>
12+
}
1013

1114
export function useActiveLocation(): UseActiveLocationResult {
1215
const router = useRouter()
@@ -17,7 +20,7 @@ export function useActiveLocation(): UseActiveLocationResult {
1720
})
1821

1922
const activeLocation = useRouterState({
20-
select: (s) => s.location
23+
select: (s) => s.location,
2124
})
2225

2326
const activeLocationMatch = createMemo(() => {
@@ -29,7 +32,10 @@ export function useActiveLocation(): UseActiveLocationResult {
2932
})
3033

3134
const getFromPath = (from?: string) => {
32-
return createMemo(() => from ?? activeLocationMatch()?.fullPath ?? currentRouteMatch().fullPath)
35+
return createMemo(
36+
() =>
37+
from ?? activeLocationMatch()?.fullPath ?? currentRouteMatch().fullPath,
38+
)
3339
}
3440

3541
return { activeLocationMatch, getFromPath }

packages/solid-router/tests/useNavigate.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,9 +1553,7 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
15531553
Link to .. from /param/foo/a
15541554
</button>
15551555
<button
1556-
onClick={() =>
1557-
navigate({ to: '..' })
1558-
}
1556+
onClick={() => navigate({ to: '..' })}
15591557
data-testid={'link-to-previous'}
15601558
>
15611559
Link to .. from current active route

0 commit comments

Comments
 (0)