From ffe8d90161cad866b186b797c6dbc58d29ad589c Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 20 Jul 2025 19:55:37 -0600 Subject: [PATCH] fix: linting --- src/interfaces/deepLinks.ts | 8 ++++-- src/main.capacitor.ts | 3 ++- src/services/deepLinks.ts | 36 ++++++++++++++++++--------- src/views/DeepLinkErrorView.vue | 13 +++++++--- src/views/InviteOneAcceptView.vue | 5 +++- src/views/QuickActionBvcBeginView.vue | 4 +-- 6 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/interfaces/deepLinks.ts b/src/interfaces/deepLinks.ts index f5838dc2..1ced6860 100644 --- a/src/interfaces/deepLinks.ts +++ b/src/interfaces/deepLinks.ts @@ -82,7 +82,9 @@ export const baseUrlSchema = z.object({ }); // Add a union type of all valid route paths -export const VALID_DEEP_LINK_ROUTES = Object.keys(deepLinkSchemas) as readonly (keyof typeof deepLinkSchemas)[]; +export const VALID_DEEP_LINK_ROUTES = Object.keys( + deepLinkSchemas, +) as readonly (keyof typeof deepLinkSchemas)[]; export type DeepLinkParams = { [K in keyof typeof deepLinkSchemas]: z.infer<(typeof deepLinkSchemas)[K]>; @@ -94,4 +96,6 @@ export interface DeepLinkError extends Error { } // Use the type to ensure route validation -export const routeSchema = z.enum(VALID_DEEP_LINK_ROUTES as [string, ...string[]]); +export const routeSchema = z.enum( + VALID_DEEP_LINK_ROUTES as [string, ...string[]], +); diff --git a/src/main.capacitor.ts b/src/main.capacitor.ts index 42f1c38b..191d356e 100644 --- a/src/main.capacitor.ts +++ b/src/main.capacitor.ts @@ -72,7 +72,8 @@ const handleDeepLink = async (data: { url: string }) => { await deepLinkHandler.handleDeepLink(data.url); } catch (error) { logger.error("[DeepLink] Error handling deep link: ", error); - let message: string = error instanceof Error ? error.message : safeStringify(error); + let message: string = + error instanceof Error ? error.message : safeStringify(error); if (data.url) { message += `\nURL: ${data.url}`; } diff --git a/src/services/deepLinks.ts b/src/services/deepLinks.ts index 8cd6db88..4b8bdd8c 100644 --- a/src/services/deepLinks.ts +++ b/src/services/deepLinks.ts @@ -56,7 +56,10 @@ import { logConsoleAndDb } from "../db/databaseUtil"; import type { DeepLinkError } from "../interfaces/deepLinks"; // Helper function to extract the first key from a Zod object schema -function getFirstKeyFromZodObject(schema: z.ZodObject): string | undefined { +function getFirstKeyFromZodObject( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + schema: z.ZodObject, +): string | undefined { const shape = schema.shape; const keys = Object.keys(shape); return keys.length > 0 ? keys[0] : undefined; @@ -64,21 +67,25 @@ function getFirstKeyFromZodObject(schema: z.ZodObject): string | undefined /** * Maps deep link routes to their corresponding Vue router names and optional parameter keys. - * + * * It's an object where keys are the deep link routes and values are objects with 'name' and 'paramKey'. * * The paramKey is used to extract the parameter from the route path, * because "router.replace" expects the right parameter name for the route. */ export const ROUTE_MAP: Record = - Object.entries(deepLinkSchemas).reduce((acc, [routeName, schema]) => { - const paramKey = getFirstKeyFromZodObject(schema as z.ZodObject); - acc[routeName] = { - name: routeName, - paramKey + Object.entries(deepLinkSchemas).reduce( + (acc, [routeName, schema]) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const paramKey = getFirstKeyFromZodObject(schema as z.ZodObject); + acc[routeName] = { + name: routeName, + paramKey, }; return acc; - }, {} as Record); + }, + {} as Record, + ); /** * Handles processing and routing of deep links in the application. @@ -200,7 +207,10 @@ export class DeepLinkHandler { validatedQuery = await schema.parseAsync(query); } catch (error) { // For parameter validation errors, provide specific error feedback - logConsoleAndDb(`[DeepLink] Invalid parameters for route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with params: ${JSON.stringify(params)} ... and query: ${JSON.stringify(query)}`, true); + logConsoleAndDb( + `[DeepLink] Invalid parameters for route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with params: ${JSON.stringify(params)} ... and query: ${JSON.stringify(query)}`, + true, + ); await this.router.replace({ name: "deep-link-error", params, @@ -223,7 +233,10 @@ export class DeepLinkHandler { query: validatedQuery, }); } catch (error) { - logConsoleAndDb(`[DeepLink] Error routing to route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with validated params: ${JSON.stringify(validatedParams)} ... and validated query: ${JSON.stringify(validatedQuery)}`, true); + logConsoleAndDb( + `[DeepLink] Error routing to route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with validated params: ${JSON.stringify(validatedParams)} ... and validated query: ${JSON.stringify(validatedQuery)}`, + true, + ); // For parameter validation errors, provide specific error feedback await this.router.replace({ name: "deep-link-error", @@ -231,12 +244,11 @@ export class DeepLinkHandler { query: { originalPath: path, errorCode: "ROUTING_ERROR", - errorMessage: `Error routing to ${routeName}: ${(JSON.stringify(error))}`, + errorMessage: `Error routing to ${routeName}: ${JSON.stringify(error)}`, ...validatedQuery, }, }); } - } /** diff --git a/src/views/DeepLinkErrorView.vue b/src/views/DeepLinkErrorView.vue index f1c47f37..6decd859 100644 --- a/src/views/DeepLinkErrorView.vue +++ b/src/views/DeepLinkErrorView.vue @@ -31,7 +31,11 @@

Supported Deep Links

  • - timesafari://{{ routeItem }}/:{{ deepLinkSchemaKeys[routeItem] }} + timesafari://{{ routeItem }}/:{{ + deepLinkSchemaKeys[routeItem] + }}
@@ -41,7 +45,10 @@