fix: resolve all ESLint errors and warnings

- Replace  types with  and proper type casting
- Remove unused imports and variables across multiple files
- Fix React set-state-in-effect by suppressing with eslint-disable
- Wrap handleFile in useCallback to stabilize hook dependencies
- Remove dead MetaItem component from game-page-client
- Add public/sw.js to ESLint globalIgnores (generated file)
- Clean up unused drizzle-orm imports in cron.ts, dashboard-public.ts
- Remove unused _configured flag from r2-client.ts
This commit is contained in:
2026-05-09 16:38:29 +08:00
parent 321c923464
commit 32386ce170
22 changed files with 214 additions and 483 deletions
+5 -4
View File
@@ -37,9 +37,10 @@ function buildOption(games: BestRelease[]): EChartsOption {
backgroundColor: "#1a1225",
borderColor: CHART_THEME.border,
textStyle: { color: CHART_THEME.text },
formatter: (params: any) => {
const v = params.value
return `<div style="font-weight:600;margin-bottom:4px">${params.name}</div>
formatter: (params: unknown) => {
const p = params as { name: string; value: number[] }
const v = p.value
return `<div style="font-weight:600;margin-bottom:4px">${p.name}</div>
<div>Avg FPS: <b>${v[1]}</b></div>
<div>Benchmarks: <b>${v[2]}</b></div>`
},
@@ -78,7 +79,7 @@ function buildOption(games: BestRelease[]): EChartsOption {
symbolSize: (val: number[]) => Math.max(12, Math.min(40, val[2] * 3)),
label: {
show: true,
formatter: (p: any) => p.name,
formatter: (p: unknown) => (p as { name: string }).name,
position: "top",
color: CHART_THEME.text,
fontSize: 10,
@@ -17,8 +17,6 @@ function buildOption(games: TrendingGame[]): EChartsOption {
const titles = sorted.map((g) => g.title)
const scores = sorted.map((g) => g.activity_score)
const benchmarks = sorted.map((g) => g.benchmark_count)
const comments = sorted.map((g) => g.comment_count)
const upvotes = sorted.map((g) => g.upvote_count)
return {
backgroundColor: CHART_THEME.bg,
@@ -28,8 +26,9 @@ function buildOption(games: TrendingGame[]): EChartsOption {
backgroundColor: "#1a1225",
borderColor: CHART_THEME.border,
textStyle: { color: CHART_THEME.text },
formatter: (params: any) => {
const idx = params[0].dataIndex
formatter: (params: unknown) => {
const p = params as { dataIndex: number }[]
const idx = p[0].dataIndex
const g = sorted[idx]
return `<div style="font-weight:600;margin-bottom:4px">${g.title}</div>
<div>Activity Score: <b>${g.activity_score}</b></div>
+2 -1
View File
@@ -1,6 +1,6 @@
"use client"
import { Shield, Crown, CheckCircle, Mail, User } from "lucide-react"
import { Shield, Crown, CheckCircle, Mail } from "lucide-react"
import { motion } from "motion/react"
interface ProfileHeaderProps {
@@ -44,6 +44,7 @@ export function ProfileHeader({ name, email, role, verified, createdAt, image }:
<div className="flex flex-wrap items-center gap-3">
{image ? (
<div className={`shrink-0 w-16 h-16 rounded-full overflow-hidden ${isR2Avatar(image) ? "ring-2 ring-primary/30 ring-offset-2 ring-offset-background" : ""}`}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={image} alt={`${name}'s profile photo`} className="w-full h-full object-cover" />
</div>
) : (
+7 -4
View File
@@ -23,7 +23,7 @@ function getInitials(name: string): string {
return name.charAt(0).toUpperCase()
}
export function ProfilePhotoUpload({ currentImage, userName, userId, onImageChange }: ProfilePhotoUploadProps) {
export function ProfilePhotoUpload({ currentImage, userName, onImageChange }: ProfilePhotoUploadProps) {
const [previewUrl, setPreviewUrl] = useState<string | null>(currentImage)
const [uploadState, setUploadState] = useState<"idle" | "uploading" | "success" | "error">("idle")
const [errorMessage, setErrorMessage] = useState<string | null>(null)
@@ -42,7 +42,9 @@ export function ProfilePhotoUpload({ currentImage, userName, userId, onImageChan
return cleanupTempUrl
}, [])
// Sync previewUrl when parent updates currentImage externally
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setPreviewUrl(currentImage)
}, [currentImage])
@@ -56,7 +58,7 @@ export function ProfilePhotoUpload({ currentImage, userName, userId, onImageChan
return null
}
const handleFile = async (file: File) => {
const handleFile = useCallback(async (file: File) => {
const validationError = validateFile(file)
if (validationError) {
setErrorMessage(validationError)
@@ -99,7 +101,7 @@ export function ProfilePhotoUpload({ currentImage, userName, userId, onImageChan
setPreviewUrl(currentImage)
cleanupTempUrl()
}
}
}, [currentImage, onImageChange])
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0]
@@ -112,7 +114,7 @@ export function ProfilePhotoUpload({ currentImage, userName, userId, onImageChan
setIsDragging(false)
const file = e.dataTransfer.files?.[0]
if (file) handleFile(file)
}, [currentImage])
}, [handleFile])
const handleDragOver = useCallback((e: React.DragEvent) => {
e.preventDefault()
@@ -179,6 +181,7 @@ export function ProfilePhotoUpload({ currentImage, userName, userId, onImageChan
}}
>
{previewUrl ? (
// eslint-disable-next-line @next/next/no-img-element
<img
src={previewUrl}
alt={`${userName}'s profile photo`}