workspace: update eslint config

This commit is contained in:
undefined committed 2021-02-01 12:33:48 +08:00
1 parent 4e4f6688bc
commit 3a3983d38d
29 files changed
+169 -166

No files matched your search

+14 -14
View File
@@ -3,22 +3,22 @@ import { argv } from 'yargs';
import { Time } from './utils';
const instances: Record<string, Logger> = {};
type LogFunction = (format: any, ...param: any[]) => void
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug'
type LogFunction = (format: any, ...param: any[]) => void;
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug';
export interface Logger extends Record<LogType, LogFunction> { }
export class Logger {
static readonly SUCCESS = 1
static readonly ERROR = 1
static readonly INFO = 2
static readonly WARN = 2
static readonly DEBUG = 3
static baseLevel = argv.debug ? 3 : 2
static showDiff = false
static levels: Record<string, number> = {}
static lastTime = 0
static readonly SUCCESS = 1;
static readonly ERROR = 1;
static readonly INFO = 2;
static readonly WARN = 2;
static readonly DEBUG = 3;
static baseLevel = argv.debug ? 3 : 2;
static showDiff = false;
static levels: Record<string, number> = {};
static lastTime = 0;
static formatters: Record<string, (this: Logger, value: any) => string> = {
o: (value) => inspect(value).replace(/\s*\n\s*/g, ' '),
}
};
constructor(public name: string, private showDiff = false) {
if (name in instances) return instances[name];
@@ -48,7 +48,7 @@ export class Logger {
return Logger.levels[this.name] ?? Logger.baseLevel;
}
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff)
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff);
format: (format: any, ...param: any[]) => string = (...args) => {
if (args[0] instanceof Error) args[0] = args[0].stack || args[0].message;
@@ -71,7 +71,7 @@ export class Logger {
Logger.lastTime = now;
}
return format(...args);
}
};
}
global.Hydro.Logger = Logger;