diff --git a/lib/logger/cmd-serializer.ts b/lib/logger/cmd-serializer.ts index b3aabfb340edb59afb1701cf27512feee1da6c96..ba656b9d481525db122d73b8136b58928b0622ed 100644 --- a/lib/logger/cmd-serializer.ts +++ b/lib/logger/cmd-serializer.ts @@ -1,5 +1,7 @@ // istanbul ignore next -export default function (cmd: string | string[]): string | string[] { +export default function cmdSerializer( + cmd: string | string[] +): string | string[] { if (typeof cmd === 'string') { return cmd.replace(/https:\/\/[^@]*@/g, 'https://**redacted**@'); } diff --git a/lib/logger/err-serializer.ts b/lib/logger/err-serializer.ts index 8bc0b266c1ecaecd0e0b7825513df1ac33152e29..b62225f9b71c5a1d07a3158633b9531199a3bb44 100644 --- a/lib/logger/err-serializer.ts +++ b/lib/logger/err-serializer.ts @@ -2,8 +2,20 @@ import is from '@sindresorhus/is'; Error.stackTraceLimit = 20; -// eslint-disable-next-lint @typescript-eslint/explicit-module-boundary-types -export default function errSerializer(err: any): any { +interface Err { + body?: unknown; + response?: { + body?: unknown; + }; + message?: unknown; + stack?: unknown; + gotOptions?: { + auth?: unknown; + headers?: unknown; + }; +} + +export default function errSerializer(err: Err): any { const response = { ...err, }; diff --git a/lib/logger/index.ts b/lib/logger/index.ts index 499a60ec2d30c8e8887311a00b749cca70eb11ad..bdf75289e447bec62a70196a7586ff7e9bfa6ebc 100644 --- a/lib/logger/index.ts +++ b/lib/logger/index.ts @@ -111,14 +111,12 @@ export function getContext(): any { } // setMeta overrides existing meta, may remove fields if no longer existing -// eslint-disable-next-lint @typescript-eslint/explicit-module-boundary-types -export function setMeta(obj: any): void { +export function setMeta(obj: Record<string, unknown>): void { meta = { ...obj }; } // addMeta overrides or adds fields but does not remove any -// eslint-disable-next-lint @typescript-eslint/explicit-module-boundary-types -export function addMeta(obj: any): void { +export function addMeta(obj: Record<string, unknown>): void { meta = { ...meta, ...obj }; } diff --git a/lib/logger/pretty-stdout.ts b/lib/logger/pretty-stdout.ts index c43408c173df561a0fa37505b73a190f7c79791b..643fb773c3ca76cf601f60eb14865124aff3661f 100644 --- a/lib/logger/pretty-stdout.ts +++ b/lib/logger/pretty-stdout.ts @@ -50,7 +50,7 @@ export function getMeta(rec: BunyanRecord): string { return res; } const metaStr = filteredMeta - .map((field) => `${field}=${rec[field]}`) + .map((field) => `${field}=${String(rec[field])}`) .join(', '); res = ` (${metaStr})${res}`; return chalk.gray(res); diff --git a/lib/logger/utils.ts b/lib/logger/utils.ts index 944a3628564e99dbf806fc0eb781b5cebc0a544d..af1d97cd1664226c8efd33189502b3ca6c19c1dc 100644 --- a/lib/logger/utils.ts +++ b/lib/logger/utils.ts @@ -92,14 +92,17 @@ function sanitizeValue(value: any, seen = new WeakMap()): any { return valueType === 'string' ? sanitize(value) : value; } -// TODO -// eslint-disable-next-lint @typescript-eslint/explicit-module-boundary-types -export function withSanitizer(streamConfig): bunyan.Stream { +type BunyanStream = (NodeJS.WritableStream | Stream) & { + writable?: boolean; + write: (chunk: BunyanRecord, enc, cb) => void; +}; + +export function withSanitizer(streamConfig: bunyan.Stream): bunyan.Stream { if (streamConfig.type === 'rotating-file') { throw new Error("Rotating files aren't supported"); } - const stream = streamConfig.stream; + const stream = streamConfig.stream as BunyanStream; if (stream?.writable) { const write = (chunk: BunyanRecord, enc, cb): void => { const raw = sanitizeValue(chunk); @@ -114,7 +117,7 @@ export function withSanitizer(streamConfig): bunyan.Stream { ...streamConfig, type: 'raw', stream: { write }, - }; + } as bunyan.Stream; } if (streamConfig.path) {