Skip to content

Commit ab65ce0

Browse files
refactor: resolve all Biome lint warnings, zero-check clean
- Replace explicit any with proper types (unknown, specific interfaces) - Add AstroComponentFactory import for SidebarColumn - Make Swup.navigate required in global type declaration - Simplify getPostUrl overloads with biome-ignore for polymorphic case - Fix permalink type (string | undefined -> string | null) - Biome check: 0 errors, 0 warnings, 0 infos - Astro check: 0 errors, 0 warnings
1 parent ee89a18 commit ab65ce0

37 files changed

Lines changed: 139 additions & 75 deletions

src/components/atoms/Image/Image.astro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const isPublic = src.startsWith("/");
5858
5959
// TODO temporary workaround for images dynamic import
6060
// https://github.com/withastro/astro/issues/3373
61-
// biome-ignore lint/suspicious/noImplicitAnyLet: <check later>
6261
let img: ImageMetadata | undefined;
6362
if (isLocal) {
6463
const files = import.meta.glob<ImageMetadata>("../../../**", {

src/components/atoms/custom-scrollbar/CustomScrollbar.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
export interface Props {
3-
children: any;
3+
children: unknown;
44
orientation?: "horizontal" | "vertical";
55
class?: string;
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface CustomScrollbarProps {
2-
children: any;
2+
children: unknown;
33
orientation?: "horizontal" | "vertical";
44
class?: string;
55
}

src/components/control/LayoutSwitch.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ onMount(() => {
113113
window.addEventListener("layoutChange", handleCustomEvent as EventListener);
114114
115115
const setupSwup = () => {
116-
const swup = (window as any).swup;
116+
const swup = window.swup;
117117
if (swup?.hooks) {
118118
swup.hooks.on("content:replace", handleSwupEvent);
119119
swup.hooks.on("page:view", handleSwupEvent);
@@ -122,7 +122,7 @@ onMount(() => {
122122
}
123123
};
124124
125-
if ((window as any).swup) {
125+
if (window.swup) {
126126
setupSwup();
127127
} else {
128128
setTimeout(setupSwup, 200);
@@ -142,7 +142,7 @@ onMount(() => {
142142
);
143143
window.removeEventListener("popstate", handleSwupEvent);
144144
145-
const swup = (window as any).swup;
145+
const swup = window.swup;
146146
if (swup?.hooks) {
147147
swup.hooks.off("content:replace", handleSwupEvent);
148148
swup.hooks.off("page:view", handleSwupEvent);

src/components/control/ThemeSwitch.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ if (typeof window !== "undefined") {
5858
};
5959
6060
// 检查 Swup 是否已经加载
61-
if ((window as any).swup && (window as any).swup.hooks) {
62-
(window as any).swup.hooks.on("content:replace", handleContentReplace);
61+
if (window.swup?.hooks) {
62+
window.swup.hooks.on("content:replace", handleContentReplace);
6363
} else {
6464
document.addEventListener("swup:enable", () => {
65-
if ((window as any).swup && (window as any).swup.hooks) {
66-
(window as any).swup.hooks.on("content:replace", handleContentReplace);
65+
if (window.swup?.hooks) {
66+
window.swup.hooks.on("content:replace", handleContentReplace);
6767
}
6868
});
6969
}

src/components/features/pio/Pio.svelte

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const merged = {
1919
hideAboutMenu: config?.hideAboutMenu ?? pioConfig.hideAboutMenu ?? true,
2020
};
2121
22-
let widgetInstance: any = null;
22+
let widgetInstance: { destroy: () => Promise<void>; sleep: () => void } | null =
23+
null;
2324
2425
async function initWidget() {
2526
if (typeof window === "undefined") return;
@@ -70,10 +71,13 @@ async function initWidget() {
7071
// Map menus config
7172
const menusConfig = merged.menus;
7273
if (menusConfig?.items && menusConfig.items.length > 0) {
73-
const menuActions: Record<string, (widget: any) => void> = {
74+
const menuActions: Record<
75+
string,
76+
(widget: { sleep: () => void }) => void
77+
> = {
7478
home: () => (window.location.href = "/"),
7579
scrollToTop: () => window.scrollTo({ top: 0, behavior: "smooth" }),
76-
sleep: (w: any) => w.sleep(),
80+
sleep: (w) => w.sleep(),
7781
};
7882
7983
options.menus = {
@@ -113,7 +117,9 @@ onMount(() => {
113117
114118
// Lazy load via requestIdleCallback
115119
if ("requestIdleCallback" in window) {
116-
(window as any).requestIdleCallback(() => initWidget(), { timeout: 5000 });
120+
(
121+
window as unknown as { requestIdleCallback: typeof requestIdleCallback }
122+
).requestIdleCallback(() => initWidget(), { timeout: 5000 });
117123
} else {
118124
setTimeout(initWidget, 2000);
119125
}

src/components/features/posts/JsonLd.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
export interface Props {
3-
data: Record<string, any>;
3+
data: Record<string, unknown>;
44
}
55
66
const { data } = Astro.props;

src/components/features/toc/hooks/useFloatingTOC.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ export function getHeadings(
7272
let minLevel = 6;
7373

7474
allHeadings.forEach((h) => {
75-
const level = Number.parseInt(h.tagName[1]);
75+
const level = Number.parseInt(h.tagName[1], 10);
7676
if (level < minLevel) {
7777
minLevel = level;
7878
}
7979
});
8080

8181
allHeadings.forEach((heading) => {
82-
const level = Number.parseInt(heading.tagName[1]);
82+
const level = Number.parseInt(heading.tagName[1], 10);
8383
if (level < minLevel + maxLevel) {
8484
headings.push(heading as HTMLElement);
8585
}

src/components/features/toc/utils/toc-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function extractHeadings(
2424
return Array.from(headings).map((h) => ({
2525
id: h.id,
2626
text: (h.textContent || "").replace(/#+\s*$/, ""),
27-
level: Number.parseInt(h.tagName[1]),
27+
level: Number.parseInt(h.tagName[1], 10),
2828
}));
2929
}
3030

@@ -155,7 +155,7 @@ export function calculateReadingProgress(): number {
155155
* @param delay - 延迟时间(毫秒)
156156
* @returns 防抖后的函数
157157
*/
158-
export function debounce<T extends (...args: any[]) => any>(
158+
export function debounce<T extends (...args: unknown[]) => unknown>(
159159
fn: T,
160160
delay: number,
161161
): (...args: Parameters<T>) => void {

src/components/layout/SidebarColumn.astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import { SidebarTOC } from "@components/features/toc";
33
import type { MarkdownHeading } from "astro";
4+
import type { AstroComponentFactory } from "astro/runtime/server/index.js";
45
56
import { widgetManager } from "@/utils/widget-manager";
67
import { buildComponentProps } from "@/utils/widget-renderer";
@@ -82,8 +83,10 @@ const desktopStickyComponents = showDesktop
8283
function renderComponent(
8384
component: WidgetComponentConfig,
8485
index: number,
85-
): { Component: any; props: Record<string, unknown> } | null {
86-
const ComponentToRender = componentMap[component.type] as any;
86+
): { Component: AstroComponentFactory; props: Record<string, unknown> } | null {
87+
const ComponentToRender = componentMap[component.type] as
88+
| AstroComponentFactory
89+
| undefined;
8790
if (!ComponentToRender) {
8891
return null;
8992
}

0 commit comments

Comments
 (0)