fix: fix eslint errors and warnings

This commit is contained in:
Henry Li
2026-01-31 21:46:31 +08:00
parent cf961328a9
commit d3ff5f9d3c
5 changed files with 20 additions and 80 deletions

View File

@@ -7,7 +7,12 @@ const compat = new FlatCompat({
export default tseslint.config( export default tseslint.config(
{ {
ignores: [".next", "src/components/ui/**", "src/components/ai-elements/**"], ignores: [
".next",
"src/components/ui/**",
"src/components/ai-elements/**",
"*.js",
],
}, },
...compat.extends("next/core-web-vitals"), ...compat.extends("next/core-web-vitals"),
{ {

View File

@@ -8,10 +8,8 @@
"build": "next build", "build": "next build",
"check": "next lint && tsc --noEmit", "check": "next lint && tsc --noEmit",
"dev": "next dev --turbo", "dev": "next dev --turbo",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,mdx}\" --cache", "lint": "eslint . --ext .ts,.tsx",
"format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache", "lint:fix": "eslint . --ext .ts,.tsx --fix",
"lint": "next lint",
"lint:fix": "next lint --fix",
"preview": "next build && next start", "preview": "next build && next start",
"start": "next start", "start": "next start",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"

View File

@@ -2,7 +2,7 @@
import { css } from "@codemirror/lang-css"; import { css } from "@codemirror/lang-css";
import { html } from "@codemirror/lang-html"; import { html } from "@codemirror/lang-html";
import { javascript, javascriptLanguage } from "@codemirror/lang-javascript"; import { javascript } from "@codemirror/lang-javascript";
import { json } from "@codemirror/lang-json"; import { json } from "@codemirror/lang-json";
import { markdown, markdownLanguage } from "@codemirror/lang-markdown"; import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
import { python } from "@codemirror/lang-python"; import { python } from "@codemirror/lang-python";
@@ -13,9 +13,9 @@ import CodeMirror from "@uiw/react-codemirror";
import { useTheme } from "next-themes"; import { useTheme } from "next-themes";
import { useMemo } from "react"; import { useMemo } from "react";
import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { Textarea } from "../ui/textarea";
import { useThread } from "./messages/context"; import { useThread } from "./messages/context";
const customDarkTheme = monokaiInit({ const customDarkTheme = monokaiInit({
settings: { settings: {
@@ -49,7 +49,7 @@ export function CodeEditor({
readonly?: boolean; readonly?: boolean;
disabled?: boolean; disabled?: boolean;
autoFocus?: boolean; autoFocus?: boolean;
settings?: any; settings?: unknown;
}) { }) {
const { const {
thread: { isLoading }, thread: { isLoading },
@@ -98,10 +98,12 @@ export function CodeEditor({
theme={resolvedTheme === "dark" ? customDarkTheme : customLightTheme} theme={resolvedTheme === "dark" ? customDarkTheme : customLightTheme}
extensions={extensions} extensions={extensions}
basicSetup={{ basicSetup={{
foldGutter: settings?.foldGutter ?? false, foldGutter:
(settings as { foldGutter?: boolean })?.foldGutter ?? false,
highlightActiveLine: false, highlightActiveLine: false,
highlightActiveLineGutter: false, highlightActiveLineGutter: false,
lineNumbers: settings?.lineNumbers ?? false, lineNumbers:
(settings as { lineNumbers?: boolean })?.lineNumbers ?? false,
}} }}
autoFocus={autoFocus} autoFocus={autoFocus}
value={value} value={value}

View File

@@ -1,5 +1,5 @@
import type { Message } from "@langchain/langgraph-sdk"; import type { Message } from "@langchain/langgraph-sdk";
import { ExternalLinkIcon, FileIcon, LinkIcon } from "lucide-react"; import { ExternalLinkIcon, FileIcon } from "lucide-react";
import { useParams } from "next/navigation"; import { useParams } from "next/navigation";
import { memo, useMemo } from "react"; import { memo, useMemo } from "react";
import rehypeKatex from "rehype-katex"; import rehypeKatex from "rehype-katex";
@@ -409,73 +409,6 @@ function UploadedFileCard({
); );
} }
/**
* Citations list component that displays all sources at the top
*/
function CitationsList({ citations }: { citations: Citation[] }) {
if (citations.length === 0) return null;
return (
<div className="bg-muted/30 mb-4 rounded-lg border p-3">
<div className="text-muted-foreground mb-2 flex items-center gap-2 text-sm font-medium">
<LinkIcon className="size-4" />
<span>Sources ({citations.length})</span>
</div>
<div className="flex flex-wrap gap-2">
{citations.map((citation) => (
<CitationBadge key={citation.id} citation={citation} />
))}
</div>
</div>
);
}
/**
* Single citation badge in the citations list
*/
function CitationBadge({ citation }: { citation: Citation }) {
const domain = extractDomainFromUrl(citation.url);
return (
<InlineCitationCard>
<HoverCardTrigger asChild>
<a
href={citation.url}
target="_blank"
rel="noopener noreferrer"
className="inline-flex"
>
<Badge
variant="secondary"
className="hover:bg-secondary/80 cursor-pointer gap-1 rounded-full px-2.5 py-1 text-xs font-normal"
>
{domain}
<ExternalLinkIcon className="size-3" />
</Badge>
</a>
</HoverCardTrigger>
<InlineCitationCardBody>
<div className="p-3">
<InlineCitationSource
title={citation.title}
url={citation.url}
description={citation.snippet}
/>
<a
href={citation.url}
target="_blank"
rel="noopener noreferrer"
className="text-primary mt-2 inline-flex items-center gap-1 text-xs hover:underline"
>
Visit source
<ExternalLinkIcon className="size-3" />
</a>
</div>
</InlineCitationCardBody>
</InlineCitationCard>
);
}
/** /**
* Citation link component that renders as a hover card badge * Citation link component that renders as a hover card badge
*/ */

View File

@@ -51,8 +51,10 @@ export async function uploadFiles(
); );
if (!response.ok) { if (!response.ok) {
const error = await response.json().catch(() => ({ detail: "Upload failed" })); const error = await response
throw new Error(error.detail || "Upload failed"); .json()
.catch(() => ({ detail: "Upload failed" }));
throw new Error(error.detail ?? "Upload failed");
} }
return response.json(); return response.json();