From c64734cbd980dad79ebc04015a16de0b9f654325 Mon Sep 17 00:00:00 2001 From: "Xin Du (Clark)" Date: Thu, 6 Jun 2019 17:56:33 +0100 Subject: [PATCH] use unknown instead of any (#486) --- flags/mod.ts | 2 +- log/logger.ts | 22 +++++++--------------- log/mod.ts | 15 +++++---------- log/test.ts | 5 +++-- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/flags/mod.ts b/flags/mod.ts index 7b4451a02d4cba..0ebaaf52eb158e 100644 --- a/flags/mod.ts +++ b/flags/mod.ts @@ -4,7 +4,7 @@ export interface ArgParsingOptions { boolean?: boolean | string | string[]; alias?: { [key: string]: string | string[] }; string?: string | string[]; - default?: { [key: string]: unknown }; // eslint-disable-line @typescript-eslint/no-explicit-any + default?: { [key: string]: unknown }; "--"?: boolean; stopEarly?: boolean; } diff --git a/log/logger.ts b/log/logger.ts index 4150fb524be63b..7ef96e15abacf6 100644 --- a/log/logger.ts +++ b/log/logger.ts @@ -4,8 +4,7 @@ import { BaseHandler } from "./handlers.ts"; export interface LogRecord { msg: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - args: any[]; + args: unknown[]; datetime: Date; level: number; levelName: string; @@ -24,8 +23,7 @@ export class Logger { this.handlers = handlers || []; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - _log(level: number, msg: string, ...args: any[]): void { + _log(level: number, msg: string, ...args: unknown[]): void { if (this.level > level) return; // TODO: it'd be a good idea to make it immutable, so @@ -38,7 +36,6 @@ export class Logger { level: level, levelName: getLevelName(level) }; - this.handlers.forEach( (handler): void => { handler.handle(record); @@ -46,28 +43,23 @@ export class Logger { ); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - debug(msg: string, ...args: any[]): void { + debug(msg: string, ...args: unknown[]): void { this._log(LogLevel.DEBUG, msg, ...args); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - info(msg: string, ...args: any[]): void { + info(msg: string, ...args: unknown[]): void { this._log(LogLevel.INFO, msg, ...args); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - warning(msg: string, ...args: any[]): void { + warning(msg: string, ...args: unknown[]): void { this._log(LogLevel.WARNING, msg, ...args); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - error(msg: string, ...args: any[]): void { + error(msg: string, ...args: unknown[]): void { this._log(LogLevel.ERROR, msg, ...args); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - critical(msg: string, ...args: any[]): void { + critical(msg: string, ...args: unknown[]): void { this._log(LogLevel.CRITICAL, msg, ...args); } } diff --git a/log/mod.ts b/log/mod.ts index d294cdc07377b5..cb166376ed4ad7 100644 --- a/log/mod.ts +++ b/log/mod.ts @@ -62,20 +62,15 @@ export function getLogger(name?: string): Logger { return state.loggers.get(name)!; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const debug = (msg: string, ...args: any[]): void => +export const debug = (msg: string, ...args: unknown[]): void => getLogger("default").debug(msg, ...args); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const info = (msg: string, ...args: any[]): void => +export const info = (msg: string, ...args: unknown[]): void => getLogger("default").info(msg, ...args); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const warning = (msg: string, ...args: any[]): void => +export const warning = (msg: string, ...args: unknown[]): void => getLogger("default").warning(msg, ...args); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const error = (msg: string, ...args: any[]): void => +export const error = (msg: string, ...args: unknown[]): void => getLogger("default").error(msg, ...args); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const critical = (msg: string, ...args: any[]): void => +export const critical = (msg: string, ...args: unknown[]): void => getLogger("default").critical(msg, ...args); export async function setup(config: LogConfig): Promise { diff --git a/log/test.ts b/log/test.ts index c42c7ed38cf611..9be1ec2a1f59d6 100644 --- a/log/test.ts +++ b/log/test.ts @@ -16,8 +16,9 @@ class TestHandler extends log.handlers.BaseHandler { } test(async function defaultHandlers(): Promise { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const loggers: { [key: string]: (msg: string, ...args: any[]) => void } = { + const loggers: { + [key: string]: (msg: string, ...args: unknown[]) => void; + } = { DEBUG: log.debug, INFO: log.info, WARNING: log.warning,