Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to Prettier 3 #2467

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"lint-staged": "^15.2.10",
"minimist": "^1.2.8",
"p-series": "^3.0.0",
"prettier": "^2.8.8",
"prettier": "^3.5.2",
"semver": "^7.6.3",
"typedoc": "^0.26.11",
"typedoc-plugin-markdown": "^4.2.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/__tests__/RouterLink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function createLocations<
normalized: RouteLocationResolved
toResolve?: MatcherLocationRaw & Required<RouteQueryAndHash>
}
>
>,
>(locs: T) {
return locs
}
Expand Down
135 changes: 81 additions & 54 deletions packages/router/__tests__/guards/guardsContext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ const component = {
describe('beforeRouteLeave', () => {
it('invokes with the component context', async () => {
expect.assertions(2)
const spy = vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
})
const spy = vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
})
const WithLeave = defineComponent({
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
Expand Down Expand Up @@ -54,23 +57,29 @@ describe('beforeRouteLeave', () => {
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})
const WithLeaveTwo = defineComponent({
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})

const router = createRouter({
Expand Down Expand Up @@ -108,23 +117,29 @@ describe('beforeRouteLeave', () => {
template: `<router-view/>`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})
const WithLeave = defineComponent({
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})

const router = createRouter({
Expand Down Expand Up @@ -167,34 +182,43 @@ describe('beforeRouteLeave', () => {
`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})
const WithLeaveOne = defineComponent({
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})
const WithLeaveTwo = defineComponent({
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
data: () => ({ counter: 0 }),
beforeRouteLeave: vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
}),
beforeRouteLeave: vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
}),
})

const router = createRouter({
Expand Down Expand Up @@ -235,12 +259,15 @@ describe('beforeRouteLeave', () => {
describe('beforeRouteUpdate', () => {
it('invokes with the component context', async () => {
expect.assertions(2)
const spy = vi
.fn()
.mockImplementationOnce(function (this: any, to, from, next) {
expect(typeof this.counter).toBe('number')
next()
})
const spy = vi.fn().mockImplementationOnce(function (
this: any,
to,
from,
next
) {
expect(typeof this.counter).toBe('number')
next()
})
const WithParam = defineComponent({
template: `text`,
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
Expand Down
2 changes: 1 addition & 1 deletion packages/router/__tests__/lazyLoading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createLazyComponent() {
const [promise, resolve, reject] = fakePromise()

return {
component: vi.fn(() => promise.then(() => ({} as RouteComponent))),
component: vi.fn(() => promise.then(() => ({}) as RouteComponent)),
promise,
resolve,
reject,
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/encoding/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/guards-instances/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/hash/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/keep-alive/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/modal/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/multi-app/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/scroll-behavior/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/suspense/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/e2e/transitions/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/RouterLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,5 +455,5 @@ const getLinkClass = (
propClass != null
? propClass
: globalClass != null
? globalClass
: defaultClass
? globalClass
: defaultClass
4 changes: 2 additions & 2 deletions packages/router/src/RouterView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ export const RouterViewImpl = /*#__PURE__*/ defineComponent({
? routePropsOption === true
? route.params
: typeof routePropsOption === 'function'
? routePropsOption(route)
: routePropsOption
? routePropsOption(route)
: routePropsOption
: null

const onVnodeUnmounted: VNodeProps['onVnodeUnmounted'] = vnode => {
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ function isSameRouteLocationParamsValue(
return isArray(a)
? isEquivalentArray(a, b)
: isArray(b)
? isEquivalentArray(b, a)
: a === b
? isEquivalentArray(b, a)
: a === b
}

/**
Expand Down
61 changes: 33 additions & 28 deletions packages/router/src/navigationGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,35 +360,40 @@ export function loadRouteLocation(
record =>
record.components &&
Promise.all(
Object.keys(record.components).reduce((promises, name) => {
const rawComponent = record.components![name]
if (
typeof rawComponent === 'function' &&
!('displayName' in rawComponent)
) {
promises.push(
(rawComponent as Lazy<RouteComponent>)().then(resolved => {
if (!resolved)
return Promise.reject(
new Error(
`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`
)
)
Object.keys(record.components).reduce(
(promises, name) => {
const rawComponent = record.components![name]
if (
typeof rawComponent === 'function' &&
!('displayName' in rawComponent)
) {
promises.push(
(rawComponent as Lazy<RouteComponent>)().then(
resolved => {
if (!resolved)
return Promise.reject(
new Error(
`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`
)
)

const resolvedComponent = isESModule(resolved)
? resolved.default
: resolved
// keep the resolved module for plugins like data loaders
record.mods[name] = resolved
// replace the function with the resolved component
// cannot be null or undefined because we went into the for loop
record.components![name] = resolvedComponent
return
})
)
}
return promises
}, [] as Array<Promise<RouteComponent | null | undefined>>)
const resolvedComponent = isESModule(resolved)
? resolved.default
: resolved
// keep the resolved module for plugins like data loaders
record.mods[name] = resolved
// replace the function with the resolved component
// cannot be null or undefined because we went into the for loop
record.components![name] = resolvedComponent
return
}
)
)
}
return promises
},
[] as Array<Promise<RouteComponent | null | undefined>>
)
)
)
).then(() => route as RouteLocationNormalizedLoaded)
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export function normalizeQuery(
normalizedQuery[key] = isArray(value)
? value.map(v => (v == null ? null : '' + v))
: value == null
? value
: '' + value
? value
: '' + value
}
}

Expand Down
Loading
Loading