Skip to content

Commit 3753ede

Browse files
chore: upgrade to Prettier 3 (#2467)
1 parent b2e0835 commit 3753ede

24 files changed

+167
-137
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"lint-staged": "^15.2.10",
4242
"minimist": "^1.2.8",
4343
"p-series": "^3.0.0",
44-
"prettier": "^2.8.8",
44+
"prettier": "^3.5.2",
4545
"semver": "^7.6.3",
4646
"simple-git-hooks": "^2.11.1",
4747
"typedoc": "^0.26.11",

packages/playground/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/__tests__/RouterLink.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function createLocations<
4747
normalized: RouteLocationResolved
4848
toResolve?: MatcherLocationRaw & Required<RouteQueryAndHash>
4949
}
50-
>
50+
>,
5151
>(locs: T) {
5252
return locs
5353
}

packages/router/__tests__/guards/guardsContext.spec.ts

+81-54
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ const component = {
1212
describe('beforeRouteLeave', () => {
1313
it('invokes with the component context', async () => {
1414
expect.assertions(2)
15-
const spy = vi
16-
.fn()
17-
.mockImplementationOnce(function (this: any, to, from, next) {
18-
expect(typeof this.counter).toBe('number')
19-
next()
20-
})
15+
const spy = vi.fn().mockImplementationOnce(function (
16+
this: any,
17+
to,
18+
from,
19+
next
20+
) {
21+
expect(typeof this.counter).toBe('number')
22+
next()
23+
})
2124
const WithLeave = defineComponent({
2225
template: `text`,
2326
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
@@ -54,23 +57,29 @@ describe('beforeRouteLeave', () => {
5457
template: `text`,
5558
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
5659
data: () => ({ counter: 0 }),
57-
beforeRouteLeave: vi
58-
.fn()
59-
.mockImplementationOnce(function (this: any, to, from, next) {
60-
expect(typeof this.counter).toBe('number')
61-
next()
62-
}),
60+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
61+
this: any,
62+
to,
63+
from,
64+
next
65+
) {
66+
expect(typeof this.counter).toBe('number')
67+
next()
68+
}),
6369
})
6470
const WithLeaveTwo = defineComponent({
6571
template: `text`,
6672
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
6773
data: () => ({ counter: 0 }),
68-
beforeRouteLeave: vi
69-
.fn()
70-
.mockImplementationOnce(function (this: any, to, from, next) {
71-
expect(typeof this.counter).toBe('number')
72-
next()
73-
}),
74+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
75+
this: any,
76+
to,
77+
from,
78+
next
79+
) {
80+
expect(typeof this.counter).toBe('number')
81+
next()
82+
}),
7483
})
7584

7685
const router = createRouter({
@@ -108,23 +117,29 @@ describe('beforeRouteLeave', () => {
108117
template: `<router-view/>`,
109118
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
110119
data: () => ({ counter: 0 }),
111-
beforeRouteLeave: vi
112-
.fn()
113-
.mockImplementationOnce(function (this: any, to, from, next) {
114-
expect(typeof this.counter).toBe('number')
115-
next()
116-
}),
120+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
121+
this: any,
122+
to,
123+
from,
124+
next
125+
) {
126+
expect(typeof this.counter).toBe('number')
127+
next()
128+
}),
117129
})
118130
const WithLeave = defineComponent({
119131
template: `text`,
120132
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
121133
data: () => ({ counter: 0 }),
122-
beforeRouteLeave: vi
123-
.fn()
124-
.mockImplementationOnce(function (this: any, to, from, next) {
125-
expect(typeof this.counter).toBe('number')
126-
next()
127-
}),
134+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
135+
this: any,
136+
to,
137+
from,
138+
next
139+
) {
140+
expect(typeof this.counter).toBe('number')
141+
next()
142+
}),
128143
})
129144

130145
const router = createRouter({
@@ -167,34 +182,43 @@ describe('beforeRouteLeave', () => {
167182
`,
168183
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
169184
data: () => ({ counter: 0 }),
170-
beforeRouteLeave: vi
171-
.fn()
172-
.mockImplementationOnce(function (this: any, to, from, next) {
173-
expect(typeof this.counter).toBe('number')
174-
next()
175-
}),
185+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
186+
this: any,
187+
to,
188+
from,
189+
next
190+
) {
191+
expect(typeof this.counter).toBe('number')
192+
next()
193+
}),
176194
})
177195
const WithLeaveOne = defineComponent({
178196
template: `text`,
179197
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
180198
data: () => ({ counter: 0 }),
181-
beforeRouteLeave: vi
182-
.fn()
183-
.mockImplementationOnce(function (this: any, to, from, next) {
184-
expect(typeof this.counter).toBe('number')
185-
next()
186-
}),
199+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
200+
this: any,
201+
to,
202+
from,
203+
next
204+
) {
205+
expect(typeof this.counter).toBe('number')
206+
next()
207+
}),
187208
})
188209
const WithLeaveTwo = defineComponent({
189210
template: `text`,
190211
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
191212
data: () => ({ counter: 0 }),
192-
beforeRouteLeave: vi
193-
.fn()
194-
.mockImplementationOnce(function (this: any, to, from, next) {
195-
expect(typeof this.counter).toBe('number')
196-
next()
197-
}),
213+
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
214+
this: any,
215+
to,
216+
from,
217+
next
218+
) {
219+
expect(typeof this.counter).toBe('number')
220+
next()
221+
}),
198222
})
199223

200224
const router = createRouter({
@@ -235,12 +259,15 @@ describe('beforeRouteLeave', () => {
235259
describe('beforeRouteUpdate', () => {
236260
it('invokes with the component context', async () => {
237261
expect.assertions(2)
238-
const spy = vi
239-
.fn()
240-
.mockImplementationOnce(function (this: any, to, from, next) {
241-
expect(typeof this.counter).toBe('number')
242-
next()
243-
})
262+
const spy = vi.fn().mockImplementationOnce(function (
263+
this: any,
264+
to,
265+
from,
266+
next
267+
) {
268+
expect(typeof this.counter).toBe('number')
269+
next()
270+
})
244271
const WithParam = defineComponent({
245272
template: `text`,
246273
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings

packages/router/__tests__/lazyLoading.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function createLazyComponent() {
2626
const [promise, resolve, reject] = fakePromise()
2727

2828
return {
29-
component: vi.fn(() => promise.then(() => ({} as RouteComponent))),
29+
component: vi.fn(() => promise.then(() => ({}) as RouteComponent)),
3030
promise,
3131
resolve,
3232
reject,

packages/router/e2e/encoding/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/guards-instances/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/hash/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/keep-alive/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/modal/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/multi-app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/scroll-behavior/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/suspense/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/e2e/transitions/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

packages/router/src/RouterLink.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,5 +455,5 @@ const getLinkClass = (
455455
propClass != null
456456
? propClass
457457
: globalClass != null
458-
? globalClass
459-
: defaultClass
458+
? globalClass
459+
: defaultClass

packages/router/src/RouterView.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ export const RouterViewImpl = /*#__PURE__*/ defineComponent({
154154
? routePropsOption === true
155155
? route.params
156156
: typeof routePropsOption === 'function'
157-
? routePropsOption(route)
158-
: routePropsOption
157+
? routePropsOption(route)
158+
: routePropsOption
159159
: null
160160

161161
const onVnodeUnmounted: VNodeProps['onVnodeUnmounted'] = vnode => {

packages/router/src/location.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ function isSameRouteLocationParamsValue(
175175
return isArray(a)
176176
? isEquivalentArray(a, b)
177177
: isArray(b)
178-
? isEquivalentArray(b, a)
179-
: a === b
178+
? isEquivalentArray(b, a)
179+
: a === b
180180
}
181181

182182
/**

packages/router/src/navigationGuards.ts

+33-28
Original file line numberDiff line numberDiff line change
@@ -360,35 +360,40 @@ export function loadRouteLocation(
360360
record =>
361361
record.components &&
362362
Promise.all(
363-
Object.keys(record.components).reduce((promises, name) => {
364-
const rawComponent = record.components![name]
365-
if (
366-
typeof rawComponent === 'function' &&
367-
!('displayName' in rawComponent)
368-
) {
369-
promises.push(
370-
(rawComponent as Lazy<RouteComponent>)().then(resolved => {
371-
if (!resolved)
372-
return Promise.reject(
373-
new Error(
374-
`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`
375-
)
376-
)
363+
Object.keys(record.components).reduce(
364+
(promises, name) => {
365+
const rawComponent = record.components![name]
366+
if (
367+
typeof rawComponent === 'function' &&
368+
!('displayName' in rawComponent)
369+
) {
370+
promises.push(
371+
(rawComponent as Lazy<RouteComponent>)().then(
372+
resolved => {
373+
if (!resolved)
374+
return Promise.reject(
375+
new Error(
376+
`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`
377+
)
378+
)
377379

378-
const resolvedComponent = isESModule(resolved)
379-
? resolved.default
380-
: resolved
381-
// keep the resolved module for plugins like data loaders
382-
record.mods[name] = resolved
383-
// replace the function with the resolved component
384-
// cannot be null or undefined because we went into the for loop
385-
record.components![name] = resolvedComponent
386-
return
387-
})
388-
)
389-
}
390-
return promises
391-
}, [] as Array<Promise<RouteComponent | null | undefined>>)
380+
const resolvedComponent = isESModule(resolved)
381+
? resolved.default
382+
: resolved
383+
// keep the resolved module for plugins like data loaders
384+
record.mods[name] = resolved
385+
// replace the function with the resolved component
386+
// cannot be null or undefined because we went into the for loop
387+
record.components![name] = resolvedComponent
388+
return
389+
}
390+
)
391+
)
392+
}
393+
return promises
394+
},
395+
[] as Array<Promise<RouteComponent | null | undefined>>
396+
)
392397
)
393398
)
394399
).then(() => route as RouteLocationNormalizedLoaded)

packages/router/src/query.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ export function normalizeQuery(
140140
normalizedQuery[key] = isArray(value)
141141
? value.map(v => (v == null ? null : '' + v))
142142
: value == null
143-
? value
144-
: '' + value
143+
? value
144+
: '' + value
145145
}
146146
}
147147

0 commit comments

Comments
 (0)