From 67c073e4f2a9c17f1969c0d7a33d4ebd2a160cfe Mon Sep 17 00:00:00 2001 From: Boki Date: Fri, 20 Jun 2025 09:10:57 -0400 Subject: [PATCH] more lint fixes --- libs/config/src/config-manager.ts | 4 ++-- libs/config/src/index.ts | 2 +- libs/config/src/loaders/file.loader.ts | 2 +- libs/postgres-client/src/client.ts | 6 +++--- libs/postgres-client/src/health.ts | 5 ++++- libs/questdb-client/src/client.ts | 6 +++--- libs/queue/src/queue-manager.ts | 19 +++++++++++++++---- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/libs/config/src/config-manager.ts b/libs/config/src/config-manager.ts index 0bfa701..e904b27 100644 --- a/libs/config/src/config-manager.ts +++ b/libs/config/src/config-manager.ts @@ -98,11 +98,11 @@ export class ConfigManager> { getValue(path: string): R { const config = this.get(); const keys = path.split('.'); - let value: any = config; + let value: unknown = config; for (const key of keys) { if (value && typeof value === 'object' && key in value) { - value = value[key]; + value = (value as Record)[key]; } else { throw new ConfigError(`Configuration key not found: ${path}`); } diff --git a/libs/config/src/index.ts b/libs/config/src/index.ts index 41da483..76b704f 100644 --- a/libs/config/src/index.ts +++ b/libs/config/src/index.ts @@ -110,7 +110,7 @@ export function getProviderConfig(provider: string) { if (!providers || !(provider in providers)) { throw new Error(`Provider configuration not found: ${provider}`); } - return (providers as any)[provider]; + return (providers as Record)[provider]; } // Export environment helpers diff --git a/libs/config/src/loaders/file.loader.ts b/libs/config/src/loaders/file.loader.ts index 2079340..251a61f 100644 --- a/libs/config/src/loaders/file.loader.ts +++ b/libs/config/src/loaders/file.loader.ts @@ -43,7 +43,7 @@ export class FileLoader implements ConfigLoader { try { const content = await readFile(filepath, 'utf-8'); return JSON.parse(content); - } catch (error: any) { + } catch (error: unknown) { // File not found is not an error (configs are optional) if (error.code === 'ENOENT') { return null; diff --git a/libs/postgres-client/src/client.ts b/libs/postgres-client/src/client.ts index a50d324..4974469 100644 --- a/libs/postgres-client/src/client.ts +++ b/libs/postgres-client/src/client.ts @@ -49,7 +49,7 @@ export class PostgreSQLClient { let lastError: Error | null = null; - for (let attempt = 1; attempt <= this.options.retryAttempts!; attempt++) { + for (let attempt = 1; attempt <= (this.options.retryAttempts ?? 3); attempt++) { try { this.logger.info( `Connecting to PostgreSQL (attempt ${attempt}/${this.options.retryAttempts})...` @@ -81,8 +81,8 @@ export class PostgreSQLClient { this.pool = null; } - if (attempt < this.options.retryAttempts!) { - await this.delay(this.options.retryDelay! * attempt); + if (attempt < (this.options.retryAttempts ?? 3)) { + await this.delay((this.options.retryDelay ?? 1000) * attempt); } } } diff --git a/libs/postgres-client/src/health.ts b/libs/postgres-client/src/health.ts index 018c79e..563e887 100644 --- a/libs/postgres-client/src/health.ts +++ b/libs/postgres-client/src/health.ts @@ -68,7 +68,10 @@ export class PostgreSQLHealthMonitor { if (!this.lastHealthCheck) { await this.performHealthCheck(); } - return this.lastHealthCheck!; + if (!this.lastHealthCheck) { + throw new Error('Health check failed to produce results'); + } + return this.lastHealthCheck; } /** diff --git a/libs/questdb-client/src/client.ts b/libs/questdb-client/src/client.ts index 2049330..c279d3d 100644 --- a/libs/questdb-client/src/client.ts +++ b/libs/questdb-client/src/client.ts @@ -52,7 +52,7 @@ export class QuestDBClient { let lastError: Error | null = null; - for (let attempt = 1; attempt <= this.options.retryAttempts!; attempt++) { + for (let attempt = 1; attempt <= (this.options.retryAttempts ?? 3); attempt++) { try { this.logger.info( `Connecting to QuestDB (attempt ${attempt}/${this.options.retryAttempts})...` @@ -84,8 +84,8 @@ export class QuestDBClient { this.pgPool = null; } - if (attempt < this.options.retryAttempts!) { - await this.delay(this.options.retryDelay! * attempt); + if (attempt < (this.options.retryAttempts ?? 3)) { + await this.delay((this.options.retryDelay ?? 1000) * attempt); } } } diff --git a/libs/queue/src/queue-manager.ts b/libs/queue/src/queue-manager.ts index d1bcdbd..2b812ed 100644 --- a/libs/queue/src/queue-manager.ts +++ b/libs/queue/src/queue-manager.ts @@ -35,7 +35,9 @@ export class QueueManager { if (config.rateLimitRules && config.rateLimitRules.length > 0) { this.rateLimiter = new QueueRateLimiter(this.redisConnection); config.rateLimitRules.forEach(rule => { - this.rateLimiter!.addRule(rule); + if (this.rateLimiter) { + this.rateLimiter.addRule(rule); + } }); } @@ -113,7 +115,10 @@ export class QueueManager { getQueue(queueName: string, options: QueueOptions = {}): Queue { // Return existing queue if it exists if (this.queues.has(queueName)) { - return this.queues.get(queueName)!; + const existingQueue = this.queues.get(queueName); + if (existingQueue) { + return existingQueue; + } } // Create new queue with merged options @@ -147,7 +152,9 @@ export class QueueManager { mergedOptions.rateLimitRules.forEach(rule => { // Ensure queue name is set for queue-specific rules const ruleWithQueue = { ...rule, queueName }; - this.rateLimiter!.addRule(ruleWithQueue); + if (this.rateLimiter) { + this.rateLimiter.addRule(ruleWithQueue); + } }); } @@ -188,7 +195,11 @@ export class QueueManager { this.caches.set(queueName, cacheProvider); logger.trace('Cache created for queue', { queueName }); } - return this.caches.get(queueName)!; + const cache = this.caches.get(queueName); + if (!cache) { + throw new Error(`Expected cache for queue ${queueName} to exist`); + } + return cache; } /**