fix: Resolve web package lint and typecheck errors
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Fixes ESLint and TypeScript errors in web package to pass CI checks:

- Fixed all Quality Rails violations (14 explicit any types)
- Fixed deprecated React event types (FormEvent → SyntheticEvent)
- Fixed 26 TypeScript errors (Promise types, test mocks, HTMLElement assertions)
- Added vitest DOM matcher type definitions
- Fixed unused variables and empty functions
- Resolved 43+ additional lint errors

Typecheck:  0 errors
Lint: 542 remaining (non-blocking in CI)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-30 21:34:12 -06:00
parent c221b63d14
commit f0704db560
45 changed files with 164 additions and 108 deletions

View File

@@ -37,7 +37,7 @@ describe("useLayouts", (): void => {
{ id: "2", name: "Custom", isDefault: false, layout: [] },
];
(global.fetch as any).mockResolvedValueOnce({
(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
ok: true,
json: () => mockLayouts,
});
@@ -52,7 +52,7 @@ describe("useLayouts", (): void => {
});
it("should handle fetch errors", async (): Promise<void> => {
(global.fetch as any).mockRejectedValueOnce(new Error("API Error"));
(global.fetch as ReturnType<typeof vi.fn>).mockRejectedValueOnce(new Error("API Error"));
const { result } = renderHook(() => useLayouts(), {
wrapper: createWrapper(),
@@ -64,7 +64,7 @@ describe("useLayouts", (): void => {
});
it("should show loading state", (): void => {
(global.fetch as any).mockImplementation(() => new Promise(() => {}));
(global.fetch as ReturnType<typeof vi.fn>).mockImplementation(() => new Promise(() => {}));
const { result } = renderHook(() => useLayouts(), {
wrapper: createWrapper(),
@@ -87,7 +87,7 @@ describe("useCreateLayout", (): void => {
layout: [],
};
(global.fetch as any).mockResolvedValueOnce({
(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
ok: true,
json: () => mockLayout,
});
@@ -108,7 +108,7 @@ describe("useCreateLayout", (): void => {
});
it("should handle creation errors", async (): Promise<void> => {
(global.fetch as any).mockRejectedValueOnce(new Error("API Error"));
(global.fetch as ReturnType<typeof vi.fn>).mockRejectedValueOnce(new Error("API Error"));
const { result } = renderHook(() => useCreateLayout(), {
wrapper: createWrapper(),
@@ -138,7 +138,7 @@ describe("useUpdateLayout", (): void => {
layout: [{ i: "widget-1", x: 0, y: 0, w: 2, h: 2 }],
};
(global.fetch as any).mockResolvedValueOnce({
(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
ok: true,
json: () => mockLayout,
});
@@ -160,7 +160,7 @@ describe("useUpdateLayout", (): void => {
});
it("should handle update errors", async (): Promise<void> => {
(global.fetch as any).mockRejectedValueOnce(new Error("API Error"));
(global.fetch as ReturnType<typeof vi.fn>).mockRejectedValueOnce(new Error("API Error"));
const { result } = renderHook(() => useUpdateLayout(), {
wrapper: createWrapper(),
@@ -183,7 +183,7 @@ describe("useDeleteLayout", (): void => {
});
it("should delete a layout", async (): Promise<void> => {
(global.fetch as any).mockResolvedValueOnce({
(global.fetch as ReturnType<typeof vi.fn>).mockResolvedValueOnce({
ok: true,
json: () => ({ success: true }),
});
@@ -200,7 +200,7 @@ describe("useDeleteLayout", (): void => {
});
it("should handle deletion errors", async (): Promise<void> => {
(global.fetch as any).mockRejectedValueOnce(new Error("API Error"));
(global.fetch as ReturnType<typeof vi.fn>).mockRejectedValueOnce(new Error("API Error"));
const { result } = renderHook(() => useDeleteLayout(), {
wrapper: createWrapper(),

View File

@@ -17,14 +17,14 @@ describe("useWebSocket", (): void => {
mockSocket = {
on: vi.fn((event: string, handler: (...args: unknown[]) => void) => {
eventHandlers[event] = handler;
return mockSocket as Socket;
return mockSocket;
}) as unknown as Socket["on"],
off: vi.fn((event?: string) => {
if (event && Object.hasOwn(eventHandlers, event)) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete eventHandlers[event];
}
return mockSocket as Socket;
return mockSocket;
}) as unknown as Socket["off"],
connect: vi.fn(),
disconnect: vi.fn(),