From 2e0ab295a34229f7d858d1ef916d294779a764d7 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 (denoland/deno_std#486) Original: https://github.com/denoland/deno_std/commit/c64734cbd980dad79ebc04015a16de0b9f654325 --- 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 7b4451a02d..0ebaaf52eb 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 4150fb524b..7ef96e15ab 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 d294cdc073..cb166376ed 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 c42c7ed38c..9be1ec2a1f 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,