lint using oxlint (#106)

This commit is contained in:
Will Chen
2025-05-08 17:21:35 -07:00
committed by GitHub
parent 0e8cc26fb5
commit 2537fbb342
63 changed files with 251 additions and 292 deletions

View File

@@ -1,5 +1,4 @@
import { FileText, X } from "lucide-react";
import { useEffect } from "react";
interface AttachmentsListProps {
attachments: File[];

View File

@@ -3,11 +3,10 @@ import {
History,
PlusCircle,
GitBranch,
AlertCircle,
Info,
} from "lucide-react";
import { PanelRightClose } from "lucide-react";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { useAtom, useAtomValue } from "jotai";
import { selectedAppIdAtom } from "@/atoms/appAtoms";
import { useVersions } from "@/hooks/useVersions";
import { Button } from "../ui/button";

View File

@@ -58,17 +58,14 @@ import { useVersions } from "@/hooks/useVersions";
import { useAttachments } from "@/hooks/useAttachments";
import { AttachmentsList } from "./AttachmentsList";
import { DragDropOverlay } from "./DragDropOverlay";
import {
showError as showErrorToast,
showUncommittedFilesWarning,
} from "@/lib/toast";
import { showUncommittedFilesWarning } from "@/lib/toast";
const showTokenBarAtom = atom(false);
export function ChatInput({ chatId }: { chatId?: number }) {
const posthog = usePostHog();
const [inputValue, setInputValue] = useAtom(chatInputValueAtom);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const { settings, updateSettings, isAnyProviderSetup } = useSettings();
const { settings, updateSettings } = useSettings();
const appId = useAtomValue(selectedAppIdAtom);
const { refreshVersions } = useVersions(appId);
const { streamMessage, isStreaming, setIsStreaming, error, setError } =
@@ -76,7 +73,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
const [showError, setShowError] = useState(true);
const [isApproving, setIsApproving] = useState(false); // State for approving
const [isRejecting, setIsRejecting] = useState(false); // State for rejecting
const [messages, setMessages] = useAtom<Message[]>(chatMessagesAtom);
const [, setMessages] = useAtom<Message[]>(chatMessagesAtom);
const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom);
const [showTokenBar, setShowTokenBar] = useAtom(showTokenBarAtom);
@@ -101,7 +98,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
error: proposalError,
refreshProposal,
} = useProposal(chatId);
const { proposal, chatId: proposalChatId, messageId } = proposalResult ?? {};
const { proposal, messageId } = proposalResult ?? {};
const adjustHeight = () => {
const textarea = textareaRef.current;
@@ -620,7 +617,6 @@ function ChatInputActions({
isApproving,
isRejecting,
}: ChatInputActionsProps) {
const [autoApprove, setAutoApprove] = useState(false);
const [isDetailsVisible, setIsDetailsVisible] = useState(false);
if (proposal.type === "tip-proposal") {

View File

@@ -1,4 +1,3 @@
import { memo } from "react";
import type { Message } from "@/ipc/ipc_types";
import {
DyadMarkdownParser,

View File

@@ -1,19 +1,10 @@
import type React from "react";
import type { ReactNode } from "react";
import { useState } from "react";
import { Button } from "../ui/button";
import { IpcClient } from "../../ipc/ipc_client";
import { useAtom, useAtomValue } from "jotai";
import { chatMessagesAtom, selectedChatIdAtom } from "../../atoms/chatAtoms";
import { useStreamChat } from "@/hooks/useStreamChat";
import {
Package,
ChevronsUpDown,
ChevronsDownUp,
Loader,
ExternalLink,
Download,
} from "lucide-react";
import { Package, ChevronsUpDown, ChevronsDownUp } from "lucide-react";
import { CodeHighlight } from "./CodeHighlight";
interface DyadAddDependencyProps {
@@ -28,15 +19,14 @@ export const DyadAddDependency: React.FC<DyadAddDependencyProps> = ({
}) => {
// Extract package attribute from the node if available
const packages = node?.properties?.packages?.split(" ") || "";
const [isInstalling, setIsInstalling] = useState(false);
const [isContentVisible, setIsContentVisible] = useState(false);
const hasChildren = !!children;
return (
<div
className={`bg-(--background-lightest) dark:bg-gray-900 hover:bg-(--background-lighter) rounded-lg px-4 py-3 border my-2 ${
className={`bg-(--background-lightest) dark:bg-gray-900 hover:bg-(--background-lighter) rounded-lg px-4 py-3 border my-2 border-border ${
hasChildren ? "cursor-pointer" : ""
} ${isInstalling ? "border-amber-500" : "border-border"}`}
}`}
onClick={
hasChildren ? () => setIsContentVisible(!isContentVisible) : undefined
}
@@ -66,12 +56,6 @@ export const DyadAddDependency: React.FC<DyadAddDependencyProps> = ({
</div>
</div>
)}
{isInstalling && (
<div className="flex items-center text-amber-600 text-xs ml-2">
<Loader size={14} className="mr-1 animate-spin" />
<span>Installing...</span>
</div>
)}
</div>
{hasChildren && (
<div className="flex items-center">

View File

@@ -30,7 +30,13 @@ type ContentPiece =
| { type: "markdown"; content: string }
| { type: "custom-tag"; tagInfo: CustomTagInfo };
const customLink = ({ node, ...props }: { node?: any; [key: string]: any }) => (
const customLink = ({
node: _node,
...props
}: {
node?: any;
[key: string]: any;
}) => (
<a
{...props}
onClick={(e) => {
@@ -358,11 +364,3 @@ function renderCustomTag(
return null;
}
}
/**
* Extract attribute values from className string
*/
function extractAttribute(className: string, attrName: string): string {
const match = new RegExp(`${attrName}="([^"]*)"`, "g").exec(className);
return match ? match[1] : "";
}

View File

@@ -6,8 +6,8 @@ import {
XCircle,
Sparkles,
} from "lucide-react";
import { useAtom, useSetAtom } from "jotai";
import { chatInputValueAtom, selectedChatIdAtom } from "@/atoms/chatAtoms";
import { useAtomValue } from "jotai";
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
import { useStreamChat } from "@/hooks/useStreamChat";
interface DyadOutputProps {
type: "error" | "warning";
@@ -21,7 +21,7 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
children,
}) => {
const [isContentVisible, setIsContentVisible] = useState(false);
const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom);
const selectedChatId = useAtomValue(selectedChatIdAtom);
const { streamMessage } = useStreamChat();
// If the type is not warning, it is an error (in case LLM gives a weird "type")

View File

@@ -1,6 +1,6 @@
import { SendIcon, StopCircleIcon, X, Paperclip, Loader2 } from "lucide-react";
import { SendIcon, StopCircleIcon, Paperclip } from "lucide-react";
import type React from "react";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef } from "react";
import { ModelPicker } from "@/components/ModelPicker";
import { useSettings } from "@/hooks/useSettings";
import { homeChatInputValueAtom } from "@/atoms/chatAtoms"; // Use a different atom for home input
@@ -21,7 +21,7 @@ export function HomeChatInput({
const [inputValue, setInputValue] = useAtom(homeChatInputValueAtom);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const { settings, updateSettings, isAnyProviderSetup } = useSettings();
const { streamMessage, isStreaming, setIsStreaming } = useStreamChat({
const { isStreaming } = useStreamChat({
hasChatId: false,
}); // eslint-disable-line @typescript-eslint/no-unused-vars

View File

@@ -6,12 +6,12 @@ import { SetupBanner } from "../SetupBanner";
import { useSettings } from "@/hooks/useSettings";
import { useStreamChat } from "@/hooks/useStreamChat";
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { useAtomValue, useSetAtom } from "jotai";
import { Loader2, RefreshCw, Undo } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useVersions } from "@/hooks/useVersions";
import { selectedAppIdAtom } from "@/atoms/appAtoms";
import { showError, showSuccess, showWarning } from "@/lib/toast";
import { showError, showWarning } from "@/lib/toast";
import { IpcClient } from "@/ipc/ipc_client";
import { chatMessagesAtom } from "@/atoms/chatAtoms";
@@ -24,13 +24,13 @@ export const MessagesList = forwardRef<HTMLDivElement, MessagesListProps>(
function MessagesList({ messages, messagesEndRef }, ref) {
const appId = useAtomValue(selectedAppIdAtom);
const { versions, revertVersion } = useVersions(appId);
const { streamMessage, isStreaming, error, setError } = useStreamChat();
const { streamMessage, isStreaming } = useStreamChat();
const { isAnyProviderSetup } = useSettings();
const setMessages = useSetAtom(chatMessagesAtom);
const [isUndoLoading, setIsUndoLoading] = useState(false);
const [isRetryLoading, setIsRetryLoading] = useState(false);
const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom);
const selectedChatId = useAtomValue(selectedChatIdAtom);
return (
<div className="flex-1 overflow-y-auto p-4" ref={ref}>