清理 lint 剩余告警并更新审计文档状态
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { vi } from "vitest";
|
||||
import { mockDeep, mockReset, type DeepMockProxy } from "vitest-mock-extended";
|
||||
import { mockDeep, mockReset } from "vitest-mock-extended";
|
||||
import type { PrismaClient } from "@prisma/client";
|
||||
|
||||
export const prismaMock = mockDeep<PrismaClient>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { prismaMock, resetPrismaMock } from "@/__tests__/helpers/prisma-mock";
|
||||
import { createRequest, createRouteContext, parseJsonResponse } from "@/__tests__/helpers/api-test-utils";
|
||||
import { TEST_BLINDBOX_ROOM, TEST_USER } from "@/__tests__/helpers/fixtures";
|
||||
import { TEST_BLINDBOX_ROOM } from "@/__tests__/helpers/fixtures";
|
||||
|
||||
vi.mock("@/lib/auth", () => ({
|
||||
getAuthUserId: vi.fn().mockResolvedValue("user-1"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { createRequest, createRouteContext, parseJsonResponse } from "@/__tests__/helpers/api-test-utils";
|
||||
import { TEST_ROOM_DATA, TEST_RESTAURANT } from "@/__tests__/helpers/fixtures";
|
||||
import { createRequest, createRouteContext } from "@/__tests__/helpers/api-test-utils";
|
||||
import { TEST_ROOM_DATA } from "@/__tests__/helpers/fixtures";
|
||||
|
||||
vi.mock("@/lib/prisma", () => ({ prisma: {} }));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { createRequest, createRouteContext, parseJsonResponse } from "@/__tests__/helpers/api-test-utils";
|
||||
import { TEST_ROOM_DATA, TEST_RESTAURANT, TEST_RESTAURANT_2 } from "@/__tests__/helpers/fixtures";
|
||||
import { TEST_ROOM_DATA, TEST_RESTAURANT } from "@/__tests__/helpers/fixtures";
|
||||
|
||||
vi.mock("@/lib/prisma", () => ({ prisma: {} }));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { render, waitFor } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import { ToastContext, type ToastContextValue } from "@/hooks/useToast";
|
||||
|
||||
|
||||
@@ -121,7 +121,11 @@ function RoomCard({
|
||||
tabIndex={0}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
confirmDelete ? onCancelDelete() : onRequestDelete();
|
||||
if (confirmDelete) {
|
||||
onCancelDelete();
|
||||
} else {
|
||||
onRequestDelete();
|
||||
}
|
||||
}}
|
||||
className="flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted/40 transition-colors hover:bg-elevated hover:text-muted active:text-foreground"
|
||||
>
|
||||
@@ -276,7 +280,7 @@ export default function BlindboxLobbyPage() {
|
||||
} finally {
|
||||
setDeletingId(null);
|
||||
}
|
||||
}, [deletingId, profile, toast]);
|
||||
}, [deletingId, profile, toast, mutateRooms]);
|
||||
|
||||
return (
|
||||
<div className="relative flex min-h-dvh flex-col items-center justify-center bg-background px-6 py-6 overflow-y-auto scrollbar-none">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import Image from "next/image";
|
||||
|
||||
export default function GlobalError({
|
||||
error,
|
||||
@@ -17,7 +18,7 @@ export default function GlobalError({
|
||||
<html lang="zh-CN">
|
||||
<body style={{ margin: 0, fontFamily: "system-ui, sans-serif", background: "#0a0a0a", color: "#e5e5e5" }}>
|
||||
<div style={{ display: "flex", minHeight: "100dvh", flexDirection: "column", alignItems: "center", justifyContent: "center", padding: "1.5rem" }}>
|
||||
<img src="/error-robot.png" alt="错误" style={{ width: 120, height: 120 }} />
|
||||
<Image src="/error-robot.png" alt="错误" width={120} height={120} priority />
|
||||
<h1 style={{ marginTop: "1.5rem", fontSize: "1.25rem", fontWeight: 700 }}>应用崩溃了</h1>
|
||||
<p style={{ marginTop: "0.5rem", fontSize: "0.875rem", color: "#a3a3a3", textAlign: "center" }}>
|
||||
发生了严重错误,请尝试刷新页面
|
||||
|
||||
@@ -10,7 +10,6 @@ import Button from "@/components/Button";
|
||||
import { useRoomPolling } from "@/hooks/useRoomPolling";
|
||||
import { getUserId } from "@/lib/userId";
|
||||
import { joinRoom } from "@/lib/room";
|
||||
import { getSceneConfig } from "@/lib/sceneConfig";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
|
||||
export default function RoomPage() {
|
||||
@@ -126,8 +125,6 @@ export default function RoomPage() {
|
||||
const initialIndex = swipeCounts[userId] ?? 0;
|
||||
const ready = joined && userId && restaurants.length > 0;
|
||||
|
||||
const sceneConfig = getSceneConfig(scene);
|
||||
|
||||
if (!ready) {
|
||||
return <SwipeDeckSkeleton />;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import Input from "./Input";
|
||||
|
||||
@@ -23,7 +23,7 @@ vi.mock("./ShareCardModal", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("./RestaurantImage", () => ({
|
||||
default: ({ alt }: { alt: string }) => <img alt={alt} />,
|
||||
default: ({ alt }: { alt: string }) => <div role="img" aria-label={alt} />,
|
||||
}));
|
||||
|
||||
vi.mock("./AuthModal", () => ({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
/* eslint-disable @next/next/no-img-element -- Uses raw img for unrestricted external sources and card capture fidelity. */
|
||||
|
||||
import { useState, useCallback } from "react";
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @next/next/no-img-element -- Share card rendering requires direct img tags for html-to-image output. */
|
||||
import { Star, MapPin, Zap } from "lucide-react";
|
||||
import type { Restaurant, MatchType, SceneType } from "@/types";
|
||||
import { getSceneConfig } from "@/lib/sceneConfig";
|
||||
|
||||
@@ -83,8 +83,6 @@ export default function RoomManageModal({
|
||||
[roomId, userId, toast, onClose],
|
||||
);
|
||||
|
||||
const otherUsers = users.filter((u) => u !== userId);
|
||||
|
||||
return (
|
||||
<Modal open={open} onClose={onClose}>
|
||||
<button
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @next/next/no-img-element -- Share card rendering requires direct img tags for html-to-image output. */
|
||||
import { QRCodeSVG } from "qrcode.react";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
|
||||
@@ -299,7 +299,6 @@ export default function SwipeDeck({
|
||||
if (serverIndex === 0 && currentIndexRef.current > 0 && !resetting) {
|
||||
clearLocalState();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [swipeCounts, userId, resetting, clearLocalState]);
|
||||
|
||||
const handleReset = useCallback(async () => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import { QrCode, LogOut, Crown, Lock } from "lucide-react";
|
||||
import QrInviteModal from "./QrInviteModal";
|
||||
import RoomManageModal from "./RoomManageModal";
|
||||
import type { UserProfile, SceneType } from "@/types";
|
||||
import { getSceneConfig } from "@/lib/sceneConfig";
|
||||
|
||||
interface TopNavProps {
|
||||
roomId: string;
|
||||
@@ -34,7 +33,6 @@ export default function TopNav({
|
||||
userProfiles = {},
|
||||
scene = "eat",
|
||||
}: TopNavProps) {
|
||||
const sceneConfig = getSceneConfig(scene);
|
||||
const [showQr, setShowQr] = useState(false);
|
||||
const [showManage, setShowManage] = useState(false);
|
||||
|
||||
@@ -51,6 +49,7 @@ export default function TopNav({
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowQr(true)}
|
||||
aria-label={`邀请二维码(${roomId})${typeof userCount === "number" ? `,当前 ${userCount} 人` : ""}`}
|
||||
className="flex items-center gap-1 rounded-full bg-accent/15 px-2.5 py-1 text-xs font-semibold text-accent transition-colors active:bg-accent/25"
|
||||
>
|
||||
<QrCode size={13} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { renderHook, waitFor, act } from "@testing-library/react";
|
||||
import { renderHook } from "@testing-library/react";
|
||||
|
||||
let esInstances: {
|
||||
url: string;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { ApiError, requireUserId, apiHandler } from "@/lib/api";
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
TEST_USER_2,
|
||||
TEST_RESTAURANT,
|
||||
TEST_RESTAURANT_2,
|
||||
TEST_RESTAURANT_3,
|
||||
TEST_ROOM_DATA,
|
||||
} from "@/__tests__/helpers/fixtures";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user