Skip to content

Commit

Permalink
Use array functions
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Nov 27, 2023
1 parent f57de2e commit b656f28
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
10 changes: 4 additions & 6 deletions decorators/addToLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
*/
import type { LogClass } from '../types'

export default function addToLogs<T extends LogClass>(...logs: string[]) {
return function actualDecorator(
target: T,
context: ClassDecoratorContext<T>,
): T {
const addToLogs = <T extends LogClass>(...logs: string[]) =>
function actualDecorator(target: T, context: ClassDecoratorContext<T>): T {
class LogsDecorator extends target {
public error(...args: any[]): void {
this.commonLog('error', ...args)
Expand Down Expand Up @@ -46,4 +43,5 @@ export default function addToLogs<T extends LogClass>(...logs: string[]) {

return LogsDecorator
}
}

export default addToLogs
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const envMapping = {
node: 'node',
}

function convertIntoEslintFlatConfig(config) {
const convertIntoEslintFlatConfig = (config) => {
const { env, globals, plugins, parserOptions, ...oldConfig } = config
return {
...oldConfig,
Expand Down
11 changes: 5 additions & 6 deletions mixins/withAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends HomeyClass>(base: T): APIClass & T {
return class extends base {
const withAPI = <T extends HomeyClass>(base: T): APIClass & T =>
class extends base {
public api: AxiosInstance = axios.create()

public constructor(...args: any[]) {
Expand Down Expand Up @@ -91,4 +89,5 @@ export default function withAPI<T extends HomeyClass>(base: T): APIClass & T {
}
}
}
}

export default withAPI

0 comments on commit b656f28

Please sign in to comment.