From a980ee8fcd7a3b9fca399c345d5aee1e344c3282 Mon Sep 17 00:00:00 2001 From: denshooter Date: Sat, 10 Jan 2026 16:54:28 +0100 Subject: [PATCH] Fix runtime errors: PerformanceObserver, localStorage, crypto.randomUUID, hydration issues, and linting errors --- app/api/analytics/performance/route.ts | 3 ++- app/components/KernelPanic404.tsx | 29 +++++++++++++------------- app/components/Projects.tsx | 2 +- app/editor/page.tsx | 2 +- app/manage/page.tsx | 2 +- app/projects/[slug]/page.tsx | 3 +-- components/AnalyticsDashboard.tsx | 2 -- lib/useWebVitals.ts | 2 +- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/api/analytics/performance/route.ts b/app/api/analytics/performance/route.ts index b85c76a..491d5ab 100644 --- a/app/api/analytics/performance/route.ts +++ b/app/api/analytics/performance/route.ts @@ -38,7 +38,8 @@ export async function GET(request: NextRequest) { cls: ((p.performance as Record)?.coreWebVitals as Record)?.cls as number || 0 })); - const avgLighthouse = projectsWithPerformance.length > 0 + // Calculate average lighthouse score (currently unused but kept for future use) + const _avgLighthouse = projectsWithPerformance.length > 0 ? Math.round(projectsWithPerformance.reduce((sum, p) => sum + p.lighthouse, 0) / projectsWithPerformance.length) : 0; diff --git a/app/components/KernelPanic404.tsx b/app/components/KernelPanic404.tsx index 3c7642c..b861552 100644 --- a/app/components/KernelPanic404.tsx +++ b/app/components/KernelPanic404.tsx @@ -28,18 +28,18 @@ export default function KernelPanic404() { let audioCtx: AudioContext | null = null; let systemFrozen = false; - let currentMusic: any = null; + let currentMusic: AudioBufferSourceNode | null = null; let hawkinsActive = false; let fsocietyActive = false; // Timers storage to clear on unmount const timers: (NodeJS.Timeout | number)[] = []; - const interval = (fn: Function, ms: number) => { + const interval = (fn: () => void, ms: number) => { const id = setInterval(fn, ms); timers.push(id); return id; }; - const timeout = (fn: Function, ms: number) => { + const timeout = (fn: () => void, ms: number) => { const id = setTimeout(fn, ms); timers.push(id); return id; @@ -49,7 +49,7 @@ export default function KernelPanic404() { function initAudio() { if (!audioCtx) { const AudioContextClass = - window.AudioContext || (window as any).webkitAudioContext; + window.AudioContext || (window as typeof window & { webkitAudioContext?: typeof AudioContext }).webkitAudioContext; if (AudioContextClass) { audioCtx = new AudioContextClass(); } @@ -444,6 +444,7 @@ export default function KernelPanic404() { } /* --- FILE SYSTEM --- */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any const fileSystem: any = { home: { type: "dir", @@ -551,7 +552,7 @@ export default function KernelPanic404() { let currentPath = fileSystem.home.children.guest; let pathStr = "~"; - let commandHistory: string[] = []; + const commandHistory: string[] = []; let historyIndex = -1; /* --- UTILS --- */ @@ -671,7 +672,7 @@ export default function KernelPanic404() { // Clear initial output output!.innerHTML = ""; - for (let msg of bootMessages) { + for (const msg of bootMessages) { printLine(msg.t, msg.type); await sleep(msg.d); } @@ -794,7 +795,7 @@ export default function KernelPanic404() { if (suggestions.length === 0) { try { playSynth("beep"); - } catch (e) {} + } catch {} return; } @@ -817,13 +818,13 @@ export default function KernelPanic404() { input.setSelectionRange(input.value.length, input.value.length); try { playSynth("beep"); - } catch (e) {} + } catch {} } else { // Multiple matches printLine(`Possible completions: ${suggestions.join(" ")}`, "log-dim"); try { playSynth("beep"); - } catch (e) {} + } catch {} } } @@ -832,7 +833,7 @@ export default function KernelPanic404() { if (systemFrozen || !input) { try { playSynth("beep"); - } catch (e) {} + } catch {} return; } @@ -871,7 +872,7 @@ export default function KernelPanic404() { args.includes("-a") || args.includes("-la") || args.includes("-l"); const longFormat = args.includes("-l") || args.includes("-la"); - let items = Object.keys(currentPath.children).filter( + const items = Object.keys(currentPath.children).filter( (n) => !n.startsWith(".") || showHidden, ); @@ -1177,7 +1178,7 @@ export default function KernelPanic404() { overlay.style.display = "none"; overlay.innerHTML = ""; - const sporeInterval = interval(() => { + const _sporeInterval = interval(() => { const spore = document.createElement("div"); spore.className = "spore"; spore.style.left = Math.random() * 100 + "%"; @@ -1187,7 +1188,7 @@ export default function KernelPanic404() { setTimeout(() => spore.remove(), 3000); }, 300); - const glitchInterval = interval(() => { + const _glitchInterval = interval(() => { if (!hawkinsActive) return; body.style.filter = "hue-rotate(180deg) contrast(1.3) brightness(0.9)"; setTimeout( @@ -1412,7 +1413,7 @@ export default function KernelPanic404() { try { playSynth("key"); - } catch (e) {} + } catch {} if (e.key === "ArrowUp" && historyIndex > 0) { historyIndex--; diff --git a/app/components/Projects.tsx b/app/components/Projects.tsx index 35f73f8..6ce341a 100644 --- a/app/components/Projects.tsx +++ b/app/components/Projects.tsx @@ -2,7 +2,7 @@ import { useState, useEffect } from "react"; import { motion, Variants } from "framer-motion"; -import { ExternalLink, Github, Layers, ArrowRight, ArrowLeft, Calendar } from "lucide-react"; +import { ExternalLink, Github, ArrowRight, Calendar } from "lucide-react"; import Link from "next/link"; import Image from "next/image"; diff --git a/app/editor/page.tsx b/app/editor/page.tsx index 507f7d8..0c82b39 100644 --- a/app/editor/page.tsx +++ b/app/editor/page.tsx @@ -59,7 +59,7 @@ function EditorPageContent() { const [isSaving, setIsSaving] = useState(false); const [isCreating, setIsCreating] = useState(!projectId); const [showPreview, setShowPreview] = useState(false); - const [isTyping, setIsTyping] = useState(false); + const [_isTyping, setIsTyping] = useState(false); const [history, setHistory] = useState([]); const [historyIndex, setHistoryIndex] = useState(-1); const [originalFormData, setOriginalFormData] = useState(null); diff --git a/app/manage/page.tsx b/app/manage/page.tsx index b4a6c3c..f643825 100644 --- a/app/manage/page.tsx +++ b/app/manage/page.tsx @@ -282,7 +282,7 @@ const AdminPage = () => { onClick={() => { try { localStorage.removeItem('admin_lockout'); - } catch (error) { + } catch { // Ignore errors } window.location.reload(); diff --git a/app/projects/[slug]/page.tsx b/app/projects/[slug]/page.tsx index 2bab9e0..7a6b4a7 100644 --- a/app/projects/[slug]/page.tsx +++ b/app/projects/[slug]/page.tsx @@ -1,12 +1,11 @@ "use client"; import { motion } from 'framer-motion'; -import { ExternalLink, Calendar, Tag, ArrowLeft, Github as GithubIcon, Share2 } from 'lucide-react'; +import { ExternalLink, Calendar, ArrowLeft, Github as GithubIcon, Share2 } from 'lucide-react'; import Link from 'next/link'; import { useParams } from 'next/navigation'; import { useState, useEffect } from 'react'; import ReactMarkdown from 'react-markdown'; -import Image from 'next/image'; interface Project { id: number; diff --git a/components/AnalyticsDashboard.tsx b/components/AnalyticsDashboard.tsx index 79aebd2..727f2a1 100644 --- a/components/AnalyticsDashboard.tsx +++ b/components/AnalyticsDashboard.tsx @@ -4,9 +4,7 @@ import { useState, useEffect, useCallback } from 'react'; import { motion } from 'framer-motion'; import { BarChart3, - TrendingUp, Eye, - Heart, Zap, Globe, Activity, diff --git a/lib/useWebVitals.ts b/lib/useWebVitals.ts index b7cd65d..505fbc1 100644 --- a/lib/useWebVitals.ts +++ b/lib/useWebVitals.ts @@ -324,7 +324,7 @@ export const useWebVitals = () => { observers.forEach(observer => { try { observer.disconnect(); - } catch (error) { + } catch { // Silently fail } });