From 4c0618b6779ae48c8cb73b0df62ea995c06c547a Mon Sep 17 00:00:00 2001 From: ZyPLJ <1767992919@qq.com> Date: Thu, 21 Aug 2025 16:44:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=20replace=20map=20with=20forEach=20?= =?UTF-8?q?to=20resolve=20biome=20lint=20error=20|=20=E8=A7=A3=E5=86=B3Git?= =?UTF-8?q?hub=20Action=20Biome=20=E4=BB=A3=E7=A0=81=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E9=94=99=E8=AF=AF=20(#601)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(utils): replace map with forEach to resolve biome lint error * fix(utils): replace map with forEach in getCategoryList for clarity * fix(utils): specify radix parameter in Number.parseInt for clarity --------- Co-authored-by: L4Ph --- src/components/ArchivePanel.svelte | 4 ++-- src/utils/content-utils.ts | 6 +++--- src/utils/setting-utils.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/ArchivePanel.svelte b/src/components/ArchivePanel.svelte index 94982a9d..22939c25 100644 --- a/src/components/ArchivePanel.svelte +++ b/src/components/ArchivePanel.svelte @@ -75,8 +75,8 @@ onMount(async () => { ); const groupedPostsArray = Object.keys(grouped).map((yearStr) => ({ - year: Number.parseInt(yearStr), - posts: grouped[Number.parseInt(yearStr)], + year: Number.parseInt(yearStr, 10), + posts: grouped[Number.parseInt(yearStr, 10)], })); groupedPostsArray.sort((a, b) => b.year - a.year); diff --git a/src/utils/content-utils.ts b/src/utils/content-utils.ts index f30b8903..ca43516d 100644 --- a/src/utils/content-utils.ts +++ b/src/utils/content-utils.ts @@ -57,8 +57,8 @@ export async function getTagList(): Promise { }); const countMap: { [key: string]: number } = {}; - allBlogPosts.map((post: { data: { tags: string[] } }) => { - post.data.tags.map((tag: string) => { + allBlogPosts.forEach((post: { data: { tags: string[] } }) => { + post.data.tags.forEach((tag: string) => { if (!countMap[tag]) countMap[tag] = 0; countMap[tag]++; }); @@ -83,7 +83,7 @@ export async function getCategoryList(): Promise { return import.meta.env.PROD ? data.draft !== true : true; }); const count: { [key: string]: number } = {}; - allBlogPosts.map((post: { data: { category: string | null } }) => { + allBlogPosts.forEach((post: { data: { category: string | null } }) => { if (!post.data.category) { const ucKey = i18n(I18nKey.uncategorized); count[ucKey] = count[ucKey] ? count[ucKey] + 1 : 1; diff --git a/src/utils/setting-utils.ts b/src/utils/setting-utils.ts index b6d7484e..232fac86 100644 --- a/src/utils/setting-utils.ts +++ b/src/utils/setting-utils.ts @@ -10,12 +10,12 @@ import type { LIGHT_DARK_MODE } from "@/types/config"; export function getDefaultHue(): number { const fallback = "250"; const configCarrier = document.getElementById("config-carrier"); - return Number.parseInt(configCarrier?.dataset.hue || fallback); + return Number.parseInt(configCarrier?.dataset.hue || fallback, 10); } export function getHue(): number { const stored = localStorage.getItem("hue"); - return stored ? Number.parseInt(stored) : getDefaultHue(); + return stored ? Number.parseInt(stored, 10) : getDefaultHue(); } export function setHue(hue: number): void {