From 29cdebb0b2f8ac22b6e952179167da621cdd8a55 Mon Sep 17 00:00:00 2001 From: Riley Kohler Date: Mon, 16 Dec 2024 11:10:17 -0500 Subject: [PATCH] fix: resolve inconsistent eslint issues --- src/app/api/auth/lib/nextauth-options.ts | 2 +- src/bot/index.ts | 2 +- src/types/forks.ts | 4 ++-- src/utils/logger.ts | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/api/auth/lib/nextauth-options.ts b/src/app/api/auth/lib/nextauth-options.ts index acb5396..a9da74d 100644 --- a/src/app/api/auth/lib/nextauth-options.ts +++ b/src/app/api/auth/lib/nextauth-options.ts @@ -29,7 +29,7 @@ export const verifySession = async (token: string | undefined) => { try { await octokit.rest.users.getAuthenticated() return true - } catch (error) { + } catch { return false } } diff --git a/src/bot/index.ts b/src/bot/index.ts index 4c7a84f..eeedbd2 100644 --- a/src/bot/index.ts +++ b/src/bot/index.ts @@ -29,7 +29,7 @@ export const getMetadata = ( try { return JSON.parse(description) as Record - } catch (error) { + } catch { botLogger.warn('Failed to parse repository description', { description }) return {} } diff --git a/src/types/forks.ts b/src/types/forks.ts index 7a37090..f322812 100644 --- a/src/types/forks.ts +++ b/src/types/forks.ts @@ -2,7 +2,7 @@ import { z } from 'zod' // this type is generated from the graphql query to support // the requirements of the primer datatable component -const forksObject = z.object({ +const ForksObject = z.object({ organization: z.object({ repositories: z.object({ totalCount: z.number(), @@ -40,4 +40,4 @@ const forksObject = z.object({ }), }) -export type ForksObject = z.infer +export type ForksObject = z.infer diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 0b655d3..b24a61f 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -7,7 +7,7 @@ import { Logger } from 'tslog' const stringify = (obj: any) => { try { return JSON.stringify(obj) - } catch (e) { + } catch { return safeStringify(obj) } } @@ -26,7 +26,7 @@ const getLoggerType = () => { } // Map logger level name to number for tsLog -const mapLevelToMethod: { [key: string]: number } = { +const mapLevelToMethod: Record = { silly: 0, trace: 1, debug: 2, @@ -39,7 +39,7 @@ const mapLevelToMethod: { [key: string]: number } = { export const logger = new Logger({ type: getLoggerType(), minLevel: - mapLevelToMethod[process.env.LOGGING_LEVEL?.toLowerCase() || 'info'], + mapLevelToMethod[process.env.LOGGING_LEVEL?.toLowerCase() ?? 'info'], maskValuesRegEx: [ /"access[-._]?token":"[^"]+"/g, /"api[-._]?key":"[^"]+"/g, @@ -70,7 +70,7 @@ export const logger = new Logger({ // set message if it's a string or set it as info if ( - Object.prototype.hasOwnProperty.call(logObjWithMeta, '0') && + Object.hasOwn(logObjWithMeta, '0') && typeof logObjWithMeta['0'] === 'string' ) { output.message = logObjWithMeta['0'] @@ -79,7 +79,7 @@ export const logger = new Logger({ } // set data - if (Object.prototype.hasOwnProperty.call(logObjWithMeta, '1')) { + if (Object.hasOwn(logObjWithMeta, '1')) { output.data = logObjWithMeta['1'] }