mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-02 22:02:13 +08:00
fix: fix eslint errors and warnings
This commit is contained in:
@@ -7,7 +7,12 @@ const compat = new FlatCompat({
|
||||
|
||||
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"),
|
||||
{
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
"build": "next build",
|
||||
"check": "next lint && tsc --noEmit",
|
||||
"dev": "next dev --turbo",
|
||||
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,mdx}\" --cache",
|
||||
"format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"lint": "eslint . --ext .ts,.tsx",
|
||||
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
||||
"preview": "next build && next start",
|
||||
"start": "next start",
|
||||
"typecheck": "tsc --noEmit"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { css } from "@codemirror/lang-css";
|
||||
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 { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
||||
import { python } from "@codemirror/lang-python";
|
||||
@@ -13,9 +13,9 @@ import CodeMirror from "@uiw/react-codemirror";
|
||||
import { useTheme } from "next-themes";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
import { Textarea } from "../ui/textarea";
|
||||
import { useThread } from "./messages/context";
|
||||
const customDarkTheme = monokaiInit({
|
||||
settings: {
|
||||
@@ -49,7 +49,7 @@ export function CodeEditor({
|
||||
readonly?: boolean;
|
||||
disabled?: boolean;
|
||||
autoFocus?: boolean;
|
||||
settings?: any;
|
||||
settings?: unknown;
|
||||
}) {
|
||||
const {
|
||||
thread: { isLoading },
|
||||
@@ -98,10 +98,12 @@ export function CodeEditor({
|
||||
theme={resolvedTheme === "dark" ? customDarkTheme : customLightTheme}
|
||||
extensions={extensions}
|
||||
basicSetup={{
|
||||
foldGutter: settings?.foldGutter ?? false,
|
||||
foldGutter:
|
||||
(settings as { foldGutter?: boolean })?.foldGutter ?? false,
|
||||
highlightActiveLine: false,
|
||||
highlightActiveLineGutter: false,
|
||||
lineNumbers: settings?.lineNumbers ?? false,
|
||||
lineNumbers:
|
||||
(settings as { lineNumbers?: boolean })?.lineNumbers ?? false,
|
||||
}}
|
||||
autoFocus={autoFocus}
|
||||
value={value}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { memo, useMemo } from "react";
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -51,8 +51,10 @@ export async function uploadFiles(
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ detail: "Upload failed" }));
|
||||
throw new Error(error.detail || "Upload failed");
|
||||
const error = await response
|
||||
.json()
|
||||
.catch(() => ({ detail: "Upload failed" }));
|
||||
throw new Error(error.detail ?? "Upload failed");
|
||||
}
|
||||
|
||||
return response.json();
|
||||
|
||||
Reference in New Issue
Block a user