From 917493748f301bcef39ad64ca101d7ad23aa1744 Mon Sep 17 00:00:00 2001 From: Arief Rachmawan <62494292+mbahArip@users.noreply.github.com> Date: Wed, 30 Apr 2025 09:47:22 +0700 Subject: [PATCH] fix: `@typescript-eslint/prefer-nullish-coalescing` when building --- src/actions/files.ts | 4 +--- src/lib/utils.server.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/actions/files.ts b/src/actions/files.ts index f748a02..8bb12d9 100644 --- a/src/actions/files.ts +++ b/src/actions/files.ts @@ -213,9 +213,7 @@ export async function GetReadme(id: string | null = null): Promise< file = data.files[0]; } else { file = data.files.find((file) => file.mimeType === "text/markdown"); - if (!file) { - file = data.files.find((file) => file.mimeType === "application/vnd.google-apps.shortcut"); - } + file ??= data.files.find((file) => file.mimeType === 'application/vnd.google-apps.shortcut'); } if (!file) diff --git a/src/lib/utils.server.ts b/src/lib/utils.server.ts index 4df235d..5751725 100644 --- a/src/lib/utils.server.ts +++ b/src/lib/utils.server.ts @@ -22,7 +22,7 @@ class EncryptionService { const iv = crypto.getRandomValues(new Uint8Array(12)); const alg = { name: "AES-GCM", iv }; - const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ? forceKey : this.key)); + const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ?? this.key)); const encodedData = new TextEncoder().encode(data); const secretKey = await crypto.subtle.importKey("raw", keyhash, alg, false, ["encrypt"]); @@ -45,7 +45,7 @@ class EncryptionService { if (!cipherText || !iv) throw new Error("Invalid hash format."); const alg = { name: "AES-GCM", iv: new Uint8Array(Buffer.from(iv, "hex")) }; - const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ? forceKey : this.key)); + const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ?? this.key)); const secretKey = await crypto.subtle.importKey("raw", keyhash, alg, false, ["decrypt"]);