From de5f10874e6bf2deaca89d35ac11e1a11a64ad59 Mon Sep 17 00:00:00 2001 From: atticusofsparta Date: Tue, 13 Feb 2024 17:41:48 -0600 Subject: [PATCH] fix(lint): disable no-any warning certain types --- .releaserc | 2 +- src/common/ArIo.ts | 6 ++++-- .../ContractStateProviders/ArNSRemoteCache.ts | 16 ++++++++++------ src/common/logger.ts | 2 ++ src/types.ts | 3 ++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.releaserc b/.releaserc index 1a955a53..df31c675 100644 --- a/.releaserc +++ b/.releaserc @@ -10,7 +10,7 @@ "prerelease": true } ], - "repositoryUrl": "https://github.com/ardriveapp/node-sdk-template", + "repositoryUrl": "https://github.com/ar-io/ar-io-sdk", "debug": "false", "plugins": [ "@semantic-release/commit-analyzer", diff --git a/src/common/ArIo.ts b/src/common/ArIo.ts index 968f70a1..af5198e2 100644 --- a/src/common/ArIo.ts +++ b/src/common/ArIo.ts @@ -57,9 +57,11 @@ export class ArIo implements ContractStateProvider { retryDelay: axiosRetry.exponentialDelay, retryCondition: (error) => { this.logger.debug(`Retrying request: ${error.message}`); - return RESPONSE_RETRY_CODES.has(error.response!.status); + return ( + !!error.response && RESPONSE_RETRY_CODES.has(error.response.status) + ); }, - }) as any as AxiosInstance; + }) as unknown as AxiosInstance; } /** diff --git a/src/common/ContractStateProviders/ArNSRemoteCache.ts b/src/common/ContractStateProviders/ArNSRemoteCache.ts index 1079bd05..50be436a 100644 --- a/src/common/ContractStateProviders/ArNSRemoteCache.ts +++ b/src/common/ContractStateProviders/ArNSRemoteCache.ts @@ -54,9 +54,11 @@ export class ArNSRemoteCache implements ContractStateProvider { retryDelay: axiosRetry.exponentialDelay, retryCondition: (error) => { this.logger.debug(`Retrying request. Error: ${error}`); - return RESPONSE_RETRY_CODES.has(error.response!.status); + return ( + !!error.response && RESPONSE_RETRY_CODES.has(error.response.status) + ); }, - }) as any as AxiosInstance; + }) as unknown as AxiosInstance; } async getContractState( @@ -68,10 +70,12 @@ export class ArNSRemoteCache implements ContractStateProvider { const contractLogger = this.logger.logger.child({ contractId }); contractLogger.debug(`Fetching contract state`); - const response = await this.http(`/contract/${contractId}`).catch( - (error) => - contractLogger.debug(`Failed to fetch contract state: ${error}`), - ); + const response = await this.http( + `/contract/${contractId}`, + ).catch((error) => { + contractLogger.debug(`Failed to fetch contract state: ${error}`); + return error; + }); if (!response) { throw new BadRequest( diff --git a/src/common/logger.ts b/src/common/logger.ts index 661c91c5..f8b18eab 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -37,6 +37,7 @@ export class ArIoWinstonLogger implements ArIoLogger { }); } + /* eslint-disable @typescript-eslint/no-explicit-any */ info(message: string, ...args: any[]) { this.logger.info(message, ...args); } @@ -60,6 +61,7 @@ export class ArIoWinstonLogger implements ArIoLogger { setLogFormat(logFormat: string) { this.logger.format = getLogFormat(logFormat); } + /* eslint-enable @typescript-eslint/no-explicit-any */ } function getLogFormat(logFormat: string) { diff --git a/src/types.ts b/src/types.ts index 4a4f1f9f..8092ce03 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,7 +21,7 @@ export interface ContractStateProvider { */ getContractState(contractId: string): Promise; } - +/* eslint-disable @typescript-eslint/no-explicit-any */ export interface ArIoLogger { setLogLevel: (level: string) => void; setLogFormat: (logFormat: string) => void; @@ -30,3 +30,4 @@ export interface ArIoLogger { error: (message: string, ...args: any[]) => void; debug: (message: string, ...args: any[]) => void; } +/* eslint-enable @typescript-eslint/no-explicit-any */