Skip to content

Commit

Permalink
chore(lint): fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hdorgeval committed Jun 16, 2020
1 parent c9231f8 commit 9219a69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
12 changes: 9 additions & 3 deletions loggers/common-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function getLogger(name: string): Logger {
return foundLogger;
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function buildLogger<MyLogger extends Logger>(myLogger: new (name: string) => MyLogger) {
return {
withName: (name: string) => {
Expand Down Expand Up @@ -170,9 +171,14 @@ export function defaultDataFormatter(data: LoggerData): string[] {
if (typeof msg === 'string') {
return msg;
}
const serializedMessage = queryString.stringify(msg as {}, ' ', '=', {
encodeURIComponent: (s: string) => s,
});
const serializedMessage = queryString.stringify(
msg as queryString.ParsedUrlQueryInput,
' ',
'=',
{
encodeURIComponent: (s: string) => s,
},
);
return serializedMessage;
});

Expand Down
14 changes: 7 additions & 7 deletions loggers/no-op-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { Logger } from './common-logger';

export class NoOpLogger implements Logger {
constructor(public readonly name: string) {}
public setLevel = () => {
public setLevel = (): NoOpLogger => {
return this;
};
public setPrefixTemplate = () => {
public setPrefixTemplate = (): NoOpLogger => {
return this;
};

public setPrefixFormatter = () => {
public setPrefixFormatter = (): NoOpLogger => {
return this;
};

public setDataFormatter = () => {
public setDataFormatter = (): NoOpLogger => {
return this;
};

Expand All @@ -23,21 +23,21 @@ export class NoOpLogger implements Logger {
* @param msg any data to log to the console
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
public info = () => {};
public info = (): void => {};

/**
* Output warning message to console
*
* @param msg any data to log to the console
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
public warn = () => {};
public warn = (): void => {};

/**
* Output error message to console
*
* @param msg any data to log to the console
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
public error = () => {};
public error = (): void => {};
}
14 changes: 7 additions & 7 deletions loggers/simple-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export class SimpleLogger implements Logger {
};

constructor(public readonly name: string) {}
public setLevel = (level: LogLevel) => {
public setLevel = (level: LogLevel): SimpleLogger => {
this.level = level;
this.formatterOption = {
...this.formatterOption,
loggerLevel: level,
};
return this;
};
public setPrefixTemplate = (template: string) => {
public setPrefixTemplate = (template: string): SimpleLogger => {
this.prefixTemplate = template;
this.formatterOption = {
...this.formatterOption,
Expand All @@ -36,12 +36,12 @@ export class SimpleLogger implements Logger {
return this;
};

public setPrefixFormatter = (formatter: (option: FormatterOption) => string) => {
public setPrefixFormatter = (formatter: (option: FormatterOption) => string): SimpleLogger => {
this.formatPrefix = formatter;
return this;
};

public setDataFormatter = (formatter: (data: LoggerData) => string[]) => {
public setDataFormatter = (formatter: (data: LoggerData) => string[]): SimpleLogger => {
this.formatData = formatter;
return this;
};
Expand All @@ -51,7 +51,7 @@ export class SimpleLogger implements Logger {
*
* @param msg any data to log to the console
*/
public info = (...msg: unknown[]) => {
public info = (...msg: unknown[]): void => {
if (this.level === 'verbose') {
const formattedData = defaultPrefixAndDataMergerForLevel(
'verbose',
Expand All @@ -70,7 +70,7 @@ export class SimpleLogger implements Logger {
*
* @param msg any data to log to the console
*/
public warn = (...msg: unknown[]) => {
public warn = (...msg: unknown[]): void => {
if (this.level === 'verbose' || this.level === 'warn') {
const formattedData = defaultPrefixAndDataMergerForLevel(
'warn',
Expand All @@ -89,7 +89,7 @@ export class SimpleLogger implements Logger {
*
* @param msg any data to log to the console
*/
public error = (...msg: unknown[]) => {
public error = (...msg: unknown[]): void => {
if (this.level === 'verbose' || this.level === 'warn' || this.level === 'error') {
const formattedData = defaultPrefixAndDataMergerForLevel(
'error',
Expand Down

0 comments on commit 9219a69

Please sign in to comment.