Skip to content

Commit

Permalink
style: up prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Feb 21, 2024
1 parent 15aa3d1 commit 4e94786
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 76 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist
.output
coverage
typed-router.d.ts
auto-imports.d.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"nodemon": "^3.0.3",
"p-series": "^3.0.0",
"pinia": "^2.1.7",
"prettier": "^2.8.8",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"semver": "^7.6.0",
Expand Down
2 changes: 1 addition & 1 deletion playground/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export {}
declare global {
const defineBasicLoader: typeof import('unplugin-vue-router/runtime')['defineBasicLoader']
const defineLoader: typeof import('unplugin-vue-router/runtime')['_defineLoader']
const defineLoader: (typeof import('unplugin-vue-router/runtime'))['_defineLoader']
const definePage: typeof import('unplugin-vue-router/runtime')['definePage']
const onBeforeRouteLeave: typeof import('vue-router/auto')['onBeforeRouteLeave']
const onBeforeRouteUpdate: typeof import('vue-router/auto')['onBeforeRouteUpdate']
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/codegen/generateRouteMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface RouteRecordInfo<
// TODO: could probably be inferred from the Params
ParamsRaw extends RouteParamsRaw = RouteParamsRaw,
Params extends RouteParams = RouteParams,
Meta extends RouteMeta = RouteMeta
Meta extends RouteMeta = RouteMeta,
> {
name: Name
path: Path
Expand Down
10 changes: 5 additions & 5 deletions src/codegen/generateRouteParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export function generateRouteParams(node: TreeNode, isRaw: boolean): string {
(param.modifier === '+'
? `ParamValueOneOrMore<${isRaw}>`
: param.modifier === '*'
? `ParamValueZeroOrMore<${isRaw}>`
: param.modifier === '?'
? `ParamValueZeroOrOne<${isRaw}>`
: `ParamValue<${isRaw}>`)
? `ParamValueZeroOrMore<${isRaw}>`
: param.modifier === '?'
? `ParamValueZeroOrOne<${isRaw}>`
: `ParamValue<${isRaw}>`)
)
.join(', ')} }`
: // no params allowed
Expand All @@ -29,7 +29,7 @@ export function generateRouteParams(node: TreeNode, isRaw: boolean): string {
*/
export type ParamValueOneOrMore<isRaw extends boolean> = [
ParamValue<isRaw>,
...ParamValue<isRaw>[]
...ParamValue<isRaw>[],
]

/**
Expand Down
4 changes: 2 additions & 2 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export function createRoutesContext(options: ResolvedOptions) {
preferDTS === false
? false
: preferDTS === true
? resolve(root, 'typed-router.d.ts')
: resolve(root, preferDTS)
? resolve(root, 'typed-router.d.ts')
: resolve(root, preferDTS)

const routeTree = new PrefixTree(options)
const editableRoutes = new EditableTreeNode(routeTree)
Expand Down
21 changes: 11 additions & 10 deletions src/core/treeNodeValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ class _TreeNodeValueBase {
nameA === nameB
? 0
: // EDITS_OVERRIDE_NAME should always be last
nameA !== EDITS_OVERRIDE_NAME &&
(nameA < nameB || nameB === EDITS_OVERRIDE_NAME)
? -1
: 1
nameA !== EDITS_OVERRIDE_NAME &&
(nameA < nameB || nameB === EDITS_OVERRIDE_NAME)
? -1
: 1
)
.reduce((acc, [_path, routeBlock]) => {
return mergeRouteRecordOverride(acc, routeBlock)
Expand Down Expand Up @@ -305,17 +305,18 @@ function parseFileSegment(
? '*'
: '?'
: currentTreeRouteParam.repeatable
? '+'
: ''
? '+'
: ''
buffer = ''
pathSegment += `:${currentTreeRouteParam.paramName}${
currentTreeRouteParam.isSplat
? '(.*)'
: // Only append () if necessary
pos < segment.length - 1 && IS_VARIABLE_CHAR_RE.test(segment[pos + 1])
? '()'
: // allow routes like /[id]_suffix to make suffix static and not part of the param
''
pos < segment.length - 1 &&
IS_VARIABLE_CHAR_RE.test(segment[pos + 1])
? '()'
: // allow routes like /[id]_suffix to make suffix static and not part of the param
''
}${currentTreeRouteParam.modifier}`
params.push(currentTreeRouteParam)
subSegments.push(currentTreeRouteParam)
Expand Down
12 changes: 6 additions & 6 deletions src/data-fetching/createDataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { _Router } from '../type-extensions/router'
*/
export interface DataLoaderEntryBase<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
> {
/**
* Data stored in the entry.
Expand Down Expand Up @@ -129,7 +129,7 @@ export function createDataLoader<Context extends DataLoaderContextBase>({
}

export interface CreateDataLoaderOptions<
Context extends DataLoaderContextBase
Context extends DataLoaderContextBase,
> {
// TODO: should return a different value than context to know if we should skip the data loader execution
// TODO: rename to make more sense e.g. load, preload
Expand Down Expand Up @@ -195,7 +195,7 @@ export interface DefineDataLoader<Context extends DataLoaderContextBase> {
*/
export interface UseDataLoader<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
> {
[IS_USE_DATA_LOADER_KEY]: true

Expand Down Expand Up @@ -241,7 +241,7 @@ export interface UseDataLoader<
*/
export interface UseDataLoaderInternals<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
> {
/**
* Loads the data from the cache if possible, otherwise loads it from the loader and awaits it.
Expand Down Expand Up @@ -283,7 +283,7 @@ export type _DataMaybeLazy<Data, isLazy extends boolean = boolean> =
*/
export interface UseDataLoaderResult<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
> {
/**
* Data returned by the loader. If the data loader is lazy, it will be undefined until the first load.
Expand Down Expand Up @@ -347,7 +347,7 @@ function _testing() {
export interface DefineLoaderFn<
Data,
Context extends DataLoaderContextBase = DataLoaderContextBase,
Route = _RouteLocationNormalizedLoaded
Route = _RouteLocationNormalizedLoaded,
> {
(route: Route, context: Context): Promise<Data>
}
4 changes: 2 additions & 2 deletions src/data-fetching/defineColadaLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
export function defineColadaLoader<
Name extends _RouteRecordName,
Data,
isLazy extends boolean
isLazy extends boolean,
>(
name: Name,
options: DefineDataLoaderOptions<isLazy, Name, Data>
Expand Down Expand Up @@ -452,7 +452,7 @@ export function defineColadaLoader<Data, isLazy extends boolean>(
export interface DefineDataLoaderOptions<
isLazy extends boolean,
Name extends _RouteRecordName,
Data
Data,
> extends DefineDataLoaderOptionsBase<isLazy>,
Omit<UseQueryOptions<unknown>, 'query' | 'key'> {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/data-fetching/defineLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { NavigationResult } from './navigation-guard'
export function defineBasicLoader<
Name extends _RouteRecordName,
Data,
isLazy extends boolean
isLazy extends boolean,
>(
name: Name,
loader: DefineLoaderFn<
Expand Down
4 changes: 2 additions & 2 deletions src/data-fetching/defineQueryLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import type { _Router } from '../type-extensions/router'
export function defineQueryLoader<
Name extends _RouteRecordName,
Data,
isLazy extends boolean
isLazy extends boolean,
>(
name: Name,
loader: DefineLoaderFn<
Expand Down Expand Up @@ -350,7 +350,7 @@ export interface DefineQueryLoaderOptions<isLazy extends boolean, Data>

export interface QueryLoaderEntry<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
> extends DataLoaderEntryBase<isLazy, Data> {
vq: UseQueryReturnType<Data, unknown>
}
Expand Down
11 changes: 5 additions & 6 deletions src/data-fetching/defineVueFireLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Ref, UnwrapRef, ref, shallowRef } from 'vue'

export function defineVueFireLoader<
Doc extends DocumentReference<unknown, DocumentData>,
isLazy extends boolean
isLazy extends boolean,
>(
loader: (route: RouteLocationNormalizedLoaded) => Doc,
opts?: DefineVueFireDataLoaderOptions<isLazy>
Expand Down Expand Up @@ -277,9 +277,8 @@ export function defineVueFireLoader<
return useDataLoader
}

type _ExtractDocumentType<Doc> = Doc extends DocumentReference<infer D, any>
? D
: unknown
type _ExtractDocumentType<Doc> =
Doc extends DocumentReference<infer D, any> ? D : unknown

export interface DefineVueFireDataLoaderOptions<isLazy extends boolean>
extends DefineDataLoaderOptionsBase<isLazy>,
Expand All @@ -292,7 +291,7 @@ export interface DefineVueFireDataLoaderOptions<isLazy extends boolean>

export interface VueFireDataLoaderEntry<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
> extends DataLoaderEntryBase<isLazy, Data> {
children: Set<VueFireDataLoaderEntry>

Expand All @@ -312,7 +311,7 @@ const DEFAULT_DEFINE_LOADER_OPTIONS = {

function createDefineVueFireLoaderEntry<
isLazy extends boolean = boolean,
Data = unknown
Data = unknown,
>(
loader: (to: RouteLocationNormalizedLoaded) => _RefFirestore<Data>,
options: Required<DefineVueFireDataLoaderOptions<isLazy>>,
Expand Down
2 changes: 1 addition & 1 deletion src/data-fetching/meta-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type _DefineLoaderEntryMap<
DataLoaderEntry extends DataLoaderEntryBase<
boolean,
unknown
> = DataLoaderEntryBase<boolean, unknown>
> = DataLoaderEntryBase<boolean, unknown>,
> = WeakMap<
// Depending on the `defineLoader()` they might use a different thing as key
// e.g. an function for basic defineLoader, a doc instance for VueFire
Expand Down
2 changes: 1 addition & 1 deletion src/data-fetching/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export let currentContext:
| readonly [
entry: DataLoaderEntryBase,
router: _Router,
route: _RouteLocationNormalizedLoaded
route: _RouteLocationNormalizedLoaded,
]
| undefined
| null
Expand Down
4 changes: 2 additions & 2 deletions src/type-extensions/RouterLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
*/
export interface RouterLinkPropsTyped<
RouteMap extends _RouteMapGeneric,
Name extends keyof RouteMap = keyof RouteMap
Name extends keyof RouteMap = keyof RouteMap,
> extends Omit<_RouterLinkProps, 'to'> {
to:
| RouteLocationAsString<RouteMap>
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface RouterLinkTyped<RouteMap extends _RouteMapGeneric> {
*/
export interface _UseLinkReturnTyped<
RouteMap extends _RouteMapGeneric,
Name extends keyof RouteMap = keyof RouteMap
Name extends keyof RouteMap = keyof RouteMap,
> {
route: ComputedRef<RouteLocationResolvedTypedList<RouteMap>[Name]>
href: ComputedRef<string>
Expand Down
2 changes: 1 addition & 1 deletion src/type-extensions/navigationGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type NavigationGuardReturn = NavigationGuardReturnTyped<RouteNamedMap>
*/
export interface NavigationGuardWithThisTyped<
T,
RouteMap extends _RouteMapGeneric
RouteMap extends _RouteMapGeneric,
> {
(
this: T,
Expand Down

0 comments on commit 4e94786

Please sign in to comment.