From 05aafde1150293ee18215ee95fdd7627bb6eb64a Mon Sep 17 00:00:00 2001 From: Mednoob Date: Sat, 12 Mar 2022 10:42:14 +0900 Subject: [PATCH] fix: mematuhi peraturan ESLint --- .../0x_Decorators/Decorators.test.ts | 21 +++++++++---------- TypeScriptBasic/0x_Decorators/Decorators.ts | 13 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/TypeScriptBasic/0x_Decorators/Decorators.test.ts b/TypeScriptBasic/0x_Decorators/Decorators.test.ts index 3cf148d..af89422 100644 --- a/TypeScriptBasic/0x_Decorators/Decorators.test.ts +++ b/TypeScriptBasic/0x_Decorators/Decorators.test.ts @@ -1,14 +1,13 @@ -import { StringUtility } from "./Decorators"; +import { StringUtility } from './Decorators'; -test("[TypeScriptBasic/0x_Decorators] Pengecekan Class Decorator", () => { - expect(new StringUtility(["Test"]).data[0]).toBe("Teks pengganti argumen pertama"); -}) +test('[TypeScriptBasic/0x_Decorators] Pengecekan Class Decorator', () => { + expect(new StringUtility(['Test']).data[0]).toBe('Teks pengganti argumen pertama'); +}); -test("[TypeScriptBasic/0x_Decorators] Pengecekan Property Decorator", () => { - // @ts-expect-error - expect(new StringUtility("abc")).toThrowError(); -}) +test('[TypeScriptBasic/0x_Decorators] Pengecekan Property Decorator', () => { + expect(new StringUtility(['abc'])).toThrowError(); +}); -test("[TypeScriptBasic/0x_Decorators] Pengecekan Method Decorator", () => { - expect(StringUtility.prototype.sambungData = () => { return "" }).toThrowError(); -}) +test('[TypeScriptBasic/0x_Decorators] Pengecekan Method Decorator', () => { + expect(StringUtility.prototype.sambungData = () => { return ''; }).toThrowError(); +}); diff --git a/TypeScriptBasic/0x_Decorators/Decorators.ts b/TypeScriptBasic/0x_Decorators/Decorators.ts index 3df2cef..8077146 100644 --- a/TypeScriptBasic/0x_Decorators/Decorators.ts +++ b/TypeScriptBasic/0x_Decorators/Decorators.ts @@ -1,18 +1,19 @@ // Penjelasan akan ditulis nanti. -function gantiArgumenConstructor(constructor: typeof StringUtility): any { +function gantiArgumenConstructor(constructor: typeof StringUtility): typeof StringUtility { return class extends constructor { constructor(args: string[]) { - super(["Teks pengganti argumen pertama", ...args]); + super(['Teks pengganti argumen pertama', ...args]); } - } + }; } -function buatMethodTidakDapatDiubah(target: any, key: string, descriptor: PropertyDescriptor) { +function buatMethodTidakDapatDiubah(target: StringUtility, key: string, descriptor: PropertyDescriptor) { descriptor.writable = false; } -function harusBerupaArray(target: any, key: string) { +function harusBerupaArray(target: StringUtility, key: string) { + // @ts-expect-error ignore error if (!Array.isArray(target[key])) { throw new Error(`${key} harus berupa array`); } @@ -41,4 +42,4 @@ class StringUtility { export { StringUtility -} +};