From b656f28c426efed8dea9fba259e0e580637d66c9 Mon Sep 17 00:00:00 2001 From: Olivier Zalmanski <88216225+OlivierZal@users.noreply.github.com> Date: Mon, 27 Nov 2023 01:39:14 +0100 Subject: [PATCH] Use array functions --- decorators/addToLogs.ts | 10 ++++------ eslint.config.js | 2 +- mixins/withAPI.ts | 11 +++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/decorators/addToLogs.ts b/decorators/addToLogs.ts index f1ba067..d9d41f1 100644 --- a/decorators/addToLogs.ts +++ b/decorators/addToLogs.ts @@ -4,11 +4,8 @@ */ import type { LogClass } from '../types' -export default function addToLogs(...logs: string[]) { - return function actualDecorator( - target: T, - context: ClassDecoratorContext, - ): T { +const addToLogs = (...logs: string[]) => + function actualDecorator(target: T, context: ClassDecoratorContext): T { class LogsDecorator extends target { public error(...args: any[]): void { this.commonLog('error', ...args) @@ -46,4 +43,5 @@ export default function addToLogs(...logs: string[]) { return LogsDecorator } -} + +export default addToLogs diff --git a/eslint.config.js b/eslint.config.js index 0e7609a..65f5ed0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -14,7 +14,7 @@ const envMapping = { node: 'node', } -function convertIntoEslintFlatConfig(config) { +const convertIntoEslintFlatConfig = (config) => { const { env, globals, plugins, parserOptions, ...oldConfig } = config return { ...oldConfig, diff --git a/mixins/withAPI.ts b/mixins/withAPI.ts index 4967879..bc8f753 100644 --- a/mixins/withAPI.ts +++ b/mixins/withAPI.ts @@ -15,12 +15,10 @@ type APIClass = new (...args: any[]) => { readonly api: AxiosInstance } -function getAPIErrorMessage(error: AxiosError): string { - return error.message -} +const getAPIErrorMessage = (error: AxiosError): string => error.message -export default function withAPI(base: T): APIClass & T { - return class extends base { +const withAPI = (base: T): APIClass & T => + class extends base { public api: AxiosInstance = axios.create() public constructor(...args: any[]) { @@ -91,4 +89,5 @@ export default function withAPI(base: T): APIClass & T { } } } -} + +export default withAPI