From 5e77ba191796db461ff3a8d02523dfdc802863f2 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Tue, 7 Oct 2025 06:40:47 +0000 Subject: [PATCH] feat: improve code quality with optional linting enhancements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace 'any' types with more specific types (Record, string) - Add return type annotations to arrow functions - Replace console.log statements with descriptive comments - Replace non-null assertions with proper null checks - Improve type safety in core plugin interfaces Linting status: ✅ 0 errors, 436 warnings (down from 452 warnings) Code quality improvements: +16 warnings resolved --- src/definitions.ts | 12 ++++++------ src/web/index.ts | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/definitions.ts b/src/definitions.ts index 5a08b00..3778c88 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -68,7 +68,7 @@ export interface NotificationEvent extends Event { detail: { id: string; action: string; - data?: any; + data?: Record; }; } @@ -200,7 +200,7 @@ export interface ContentFetchConfig { apiService?: string; database?: string; reporting?: string; - onSuccess?: (data: any) => Promise; + onSuccess?: (data: Record) => Promise; onError?: (error: Error) => Promise; onComplete?: (result: ContentFetchResult) => Promise; }; @@ -266,7 +266,7 @@ export interface DualScheduleConfiguration { export interface ContentFetchResult { success: boolean; - data?: any; + data?: Record; timestamp: number; contentAge: number; error?: string; @@ -795,7 +795,7 @@ export interface TimeSafariProjectNotification { type: 'project'; subtype: TimeSafariProjectSubtype; project: PlanSummary; - previousClaim?: any; // Previous claim data + previousClaim?: Record; // Previous claim data notificationPriority: 'high' | 'medium' | 'low'; timestamp: number; } @@ -854,8 +854,8 @@ export interface EnhancedTimeSafariNotification { // Type-specific properties (union approach) offer?: OfferSummaryRecord; project?: PlanSummary; - person?: { did: any; name?: string }; + person?: { did: string; name?: string }; item?: { id: string; name?: string; type?: string }; relevantProjects?: PlanSummary[]; - previousClaim?: any; + previousClaim?: Record; } \ No newline at end of file diff --git a/src/web/index.ts b/src/web/index.ts index 1c79a1e..eef4cd1 100644 --- a/src/web/index.ts +++ b/src/web/index.ts @@ -20,13 +20,13 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { private scheduledNotifications: Set = new Set(); private activeDid?: string; - async configure(_options: any): Promise { + async configure(_options: Record): Promise { // Web implementation placeholder - console.log('Configure called on web platform'); + // Configuration applied for web platform } async maintainRollingWindow(): Promise { - console.log('Maintain rolling window called on web platform'); + // Rolling window maintenance for web platform } async getRollingWindowStats(): Promise<{ @@ -34,7 +34,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { maintenanceNeeded: boolean; timeUntilNextMaintenance: number; }> { - console.log('Get rolling window stats called on web platform'); + // Get rolling window stats for web platform return { stats: 'Web platform - rolling window not applicable', maintenanceNeeded: false, @@ -48,7 +48,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { canSchedule: boolean; fallbackWindow: string; }> { - console.log('Get exact alarm status called on web platform'); + // Get exact alarm status for web platform return { supported: false, enabled: false, @@ -247,7 +247,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { /** * Schedule content fetch (web implementation) */ - async scheduleContentFetch(config: any): Promise { + async scheduleContentFetch(config: Record): Promise { console.log('Content fetch scheduled (web mock):', config); // Mock implementation - in real app would use Service Worker } @@ -255,7 +255,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { /** * Schedule user notification (web implementation) */ - async scheduleUserNotification(config: any): Promise { + async scheduleUserNotification(config: Record): Promise { console.log('User notification scheduled (web mock):', config); // Mock implementation - in real app would use browser notifications } @@ -263,7 +263,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { /** * Schedule dual notification (web implementation) */ - async scheduleDualNotification(config: any): Promise { + async scheduleDualNotification(config: Record): Promise { console.log('Dual notification scheduled (web mock):', config); // Mock implementation combining content fetch and user notification } @@ -381,7 +381,10 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { } // Calculate next notification time - const nextTime = this.calculateNextNotificationTime(options.time!); + if (!options.time) { + throw new Error('Time parameter is required for scheduling'); + } + const nextTime = this.calculateNextNotificationTime(options.time); const delay = nextTime.getTime() - Date.now(); if (delay > 0) { @@ -411,7 +414,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin { }); // Handle notification click - browserNotification.onclick = () => { + browserNotification.onclick = (): void => { if (notification.url) { window.open(notification.url, '_blank'); }