From e0339993aeae97e0ce77ffa430214b64007b9f6f Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Fri, 18 Apr 2025 10:53:16 -0400 Subject: [PATCH] Initial auto-fixing of linting errors. - This is the result of runing `npm lint -- -fix` --- eslint.config.js | 1 - packages/cli/src/config/args.ts | 2 +- packages/cli/src/core/gemini-client.ts | 18 ++++++++---------- packages/cli/src/core/gemini-stream.ts | 3 +-- packages/cli/src/core/history-updater.ts | 2 +- packages/cli/src/tools/grep.tool.ts | 4 ++-- packages/cli/src/tools/read-file.tool.ts | 2 +- packages/cli/src/tools/terminal.tool.ts | 4 ++-- packages/cli/src/tools/tools.ts | 8 ++++---- packages/cli/src/tools/write-file.tool.ts | 2 +- packages/cli/src/ui/components/Footer.tsx | 4 +--- packages/cli/src/ui/components/Header.tsx | 4 +--- .../cli/src/ui/components/HistoryDisplay.tsx | 8 ++++---- packages/cli/src/ui/components/InputPrompt.tsx | 2 +- packages/cli/src/ui/components/Tips.tsx | 4 +--- .../components/messages/ToolGroupMessage.tsx | 6 ++---- packages/cli/src/ui/hooks/useGeminiStream.ts | 3 +-- packages/cli/src/ui/utils/MarkdownRenderer.tsx | 2 +- .../src/utils/BackgroundTerminalAnalyzer.ts | 6 +++--- packages/cli/src/utils/getFolderStructure.ts | 2 +- 20 files changed, 37 insertions(+), 50 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 917ce7e6..dcebf242 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -53,7 +53,6 @@ export default tseslint.config( }, settings: { 'import/resolver': { - typescript: true, node: true, }, }, diff --git a/packages/cli/src/config/args.ts b/packages/cli/src/config/args.ts index f36e7e58..a71b4b66 100644 --- a/packages/cli/src/config/args.ts +++ b/packages/cli/src/config/args.ts @@ -6,7 +6,7 @@ const DEFAULT_GEMINI_MODEL = 'gemini-2.5-flash-preview-04-17'; export interface CliArgs { target_dir: string | undefined; model: string | undefined; - _: (string | number)[]; // Captures positional arguments + _: Array; // Captures positional arguments // Add other expected args here if needed // e.g., verbose?: boolean; } diff --git a/packages/cli/src/core/gemini-client.ts b/packages/cli/src/core/gemini-client.ts index c7c7b5f6..0b79a2ad 100644 --- a/packages/cli/src/core/gemini-client.ts +++ b/packages/cli/src/core/gemini-client.ts @@ -44,7 +44,7 @@ export class GeminiClient { this.ai = new GoogleGenAI({ apiKey }); } - public async startChat(): Promise { + async startChat(): Promise { const tools = toolRegistry.getToolSchemas(); const model = getModel(); @@ -75,7 +75,7 @@ ${folderStructure} try { const chat = this.ai.chats.create({ - model: model, + model, config: { systemInstruction: CoreSystemPrompt, ...this.defaultHyperParameters, @@ -103,14 +103,12 @@ ${folderStructure} } } - public addMessageToHistory(chat: Chat, message: Content): void { + addMessageToHistory(chat: Chat, message: Content): void { const history = chat.getHistory(); history.push(message); - this.ai.chats; - chat; } - public async *sendMessageStream( + async *sendMessageStream( chat: Chat, request: PartListUnion, signal?: AbortSignal, @@ -180,7 +178,7 @@ ${folderStructure} } if (pendingToolCalls.length > 0) { - const toolPromises: Promise[] = + const toolPromises: Array> = pendingToolCalls.map(async (pendingToolCall) => { const tool = toolRegistry.getTool(pendingToolCall.name); @@ -311,7 +309,7 @@ ${folderStructure} return { functionResponse: { - name: name, + name, id: executedTool.callId, response: toolOutcomePayload, }, @@ -444,7 +442,7 @@ Respond *only* in JSON format according to the following schema. Do not include * @returns A promise that resolves to the parsed JSON object matching the schema. * @throws Throws an error if the API call fails or the response is not valid JSON. */ - public async generateJson( + async generateJson( contents: Content[], schema: SchemaUnion, ): Promise { @@ -458,7 +456,7 @@ Respond *only* in JSON format according to the following schema. Do not include responseSchema: schema, responseMimeType: 'application/json', }, - contents: contents, // Pass the full Content array + contents, // Pass the full Content array }); const responseText = result.text; diff --git a/packages/cli/src/core/gemini-stream.ts b/packages/cli/src/core/gemini-stream.ts index 065d261a..314a829d 100644 --- a/packages/cli/src/core/gemini-stream.ts +++ b/packages/cli/src/core/gemini-stream.ts @@ -1,6 +1,5 @@ -import { ToolCallEvent } from '../ui/types.js'; +import { ToolCallEvent , HistoryItem } from '../ui/types.js'; import { Part } from '@google/genai'; -import { HistoryItem } from '../ui/types.js'; import { handleToolCallChunk, addErrorMessageToHistory, diff --git a/packages/cli/src/core/history-updater.ts b/packages/cli/src/core/history-updater.ts index 12dd30c0..a97c99a1 100644 --- a/packages/cli/src/core/history-updater.ts +++ b/packages/cli/src/core/history-updater.ts @@ -118,7 +118,7 @@ export const handleToolCallChunk = ( description, resultDisplay: chunk.resultDisplay, status: chunk.status, - confirmationDetails: confirmationDetails, + confirmationDetails, }; const activeGroupId = currentToolGroupIdRef.current; diff --git a/packages/cli/src/tools/grep.tool.ts b/packages/cli/src/tools/grep.tool.ts index 72e28d01..788fc76d 100644 --- a/packages/cli/src/tools/grep.tool.ts +++ b/packages/cli/src/tools/grep.tool.ts @@ -351,7 +351,7 @@ export class GrepTool extends BaseTool { results.push({ // Use relative path, or just the filename if it's in the base path itself filePath: relativeFilePath || path.basename(absoluteFilePath), - lineNumber: lineNumber, + lineNumber, line: lineContent, // Use the full extracted line content }); } @@ -555,7 +555,7 @@ export class GrepTool extends BaseTool { path.relative(absolutePath, fileAbsolutePath) || path.basename(fileAbsolutePath), lineNumber: index + 1, - line: line, + line, }); } }); diff --git a/packages/cli/src/tools/read-file.tool.ts b/packages/cli/src/tools/read-file.tool.ts index fc4dc977..98df7c12 100644 --- a/packages/cli/src/tools/read-file.tool.ts +++ b/packages/cli/src/tools/read-file.tool.ts @@ -36,7 +36,7 @@ export class ReadFileTool extends BaseTool< ReadFileToolParams, ReadFileToolResult > { - public static readonly Name: string = 'read_file'; + static readonly Name: string = 'read_file'; // Maximum number of lines to read by default private static readonly DEFAULT_MAX_LINES = 2000; diff --git a/packages/cli/src/tools/terminal.tool.ts b/packages/cli/src/tools/terminal.tool.ts index 3e2d7bf8..73f4af7d 100644 --- a/packages/cli/src/tools/terminal.tool.ts +++ b/packages/cli/src/tools/terminal.tool.ts @@ -127,7 +127,7 @@ export class TerminalTool extends BaseTool< TerminalToolParams, TerminalToolResult > { - public static Name: string = 'execute_bash_command'; + static Name: string = 'execute_bash_command'; private readonly rootDirectory: string; private readonly outputLimit: number; @@ -387,7 +387,7 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es const confirmationDetails: ToolExecuteConfirmationDetails = { title: 'Confirm Shell Command', command: params.command, - rootCommand: rootCommand, + rootCommand, description: `Execute in '${this.currentCwd}':\n${description}`, onConfirm: async (outcome: ToolConfirmationOutcome) => { if (outcome === ToolConfirmationOutcome.ProceedAlways) { diff --git a/packages/cli/src/tools/tools.ts b/packages/cli/src/tools/tools.ts index 74acb919..9df90261 100644 --- a/packages/cli/src/tools/tools.ts +++ b/packages/cli/src/tools/tools.ts @@ -76,10 +76,10 @@ export abstract class BaseTool< * @param parameterSchema JSON Schema defining the parameters */ constructor( - public readonly name: string, - public readonly displayName: string, - public readonly description: string, - public readonly parameterSchema: Record, + readonly name: string, + readonly displayName: string, + readonly description: string, + readonly parameterSchema: Record, ) {} /** diff --git a/packages/cli/src/tools/write-file.tool.ts b/packages/cli/src/tools/write-file.tool.ts index 8cf0a422..1939bca0 100644 --- a/packages/cli/src/tools/write-file.tool.ts +++ b/packages/cli/src/tools/write-file.tool.ts @@ -37,7 +37,7 @@ export class WriteFileTool extends BaseTool< WriteFileToolParams, WriteFileToolResult > { - public static readonly Name: string = 'write_file'; + static readonly Name: string = 'write_file'; private shouldAlwaysWrite = false; /** diff --git a/packages/cli/src/ui/components/Footer.tsx b/packages/cli/src/ui/components/Footer.tsx index 215a4868..6b069a2f 100644 --- a/packages/cli/src/ui/components/Footer.tsx +++ b/packages/cli/src/ui/components/Footer.tsx @@ -5,8 +5,7 @@ interface FooterProps { queryLength: number; } -const Footer: React.FC = ({ queryLength }) => { - return ( +const Footer: React.FC = ({ queryLength }) => ( {queryLength === 0 ? '? for shortcuts' : ''} @@ -14,6 +13,5 @@ const Footer: React.FC = ({ queryLength }) => { Gemini ); -}; export default Footer; diff --git a/packages/cli/src/ui/components/Header.tsx b/packages/cli/src/ui/components/Header.tsx index 37d42b57..d3f0f9d5 100644 --- a/packages/cli/src/ui/components/Header.tsx +++ b/packages/cli/src/ui/components/Header.tsx @@ -7,8 +7,7 @@ interface HeaderProps { cwd: string; } -const Header: React.FC = ({ cwd }) => { - return ( +const Header: React.FC = ({ cwd }) => ( <> {/* Static Header Art */} @@ -35,6 +34,5 @@ const Header: React.FC = ({ cwd }) => { ); -}; export default Header; diff --git a/packages/cli/src/ui/components/HistoryDisplay.tsx b/packages/cli/src/ui/components/HistoryDisplay.tsx index 285a6e30..fe0bf4c1 100644 --- a/packages/cli/src/ui/components/HistoryDisplay.tsx +++ b/packages/cli/src/ui/components/HistoryDisplay.tsx @@ -17,9 +17,9 @@ interface HistoryDisplayProps { const HistoryDisplay: React.FC = ({ history, onSubmit, -}) => { +}) => // No grouping logic needed here anymore - return ( + ( {history.map((item) => ( @@ -36,7 +36,7 @@ const HistoryDisplay: React.FC = ({ ))} - ); -}; + ) +; export default HistoryDisplay; diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx index cf28960e..f79aeaa3 100644 --- a/packages/cli/src/ui/components/InputPrompt.tsx +++ b/packages/cli/src/ui/components/InputPrompt.tsx @@ -32,6 +32,6 @@ const InputPrompt: React.FC = ({ ); -}; +} export default InputPrompt; diff --git a/packages/cli/src/ui/components/Tips.tsx b/packages/cli/src/ui/components/Tips.tsx index 88a14407..6be53360 100644 --- a/packages/cli/src/ui/components/Tips.tsx +++ b/packages/cli/src/ui/components/Tips.tsx @@ -2,8 +2,7 @@ import React from 'react'; import { Box, Text } from 'ink'; import { UI_WIDTH } from '../constants.js'; -const Tips: React.FC = () => { - return ( +const Tips: React.FC = () => ( Tips for getting started: @@ -17,6 +16,5 @@ const Tips: React.FC = () => { 4. Be specific for the best results. ); -}; export default Tips; diff --git a/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx b/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx index 7317345b..6627faee 100644 --- a/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx +++ b/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx @@ -20,8 +20,7 @@ const ToolGroupMessage: React.FC = ({ return ( - {toolCalls.map((tool) => { - return ( + {toolCalls.map((tool) => ( = ({ > )} - ); - })} + ))} {/* Optional: Add padding below the last item if needed, though ToolMessage already has some vertical space implicitly */} {/* {tools.length > 0 && } */} diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 4144d96a..63f110b5 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -3,8 +3,7 @@ import { useInput } from 'ink'; import { GeminiClient } from '../../core/gemini-client.js'; import { type Chat, type PartListUnion } from '@google/genai'; import { HistoryItem } from '../types.js'; -import { processGeminiStream } from '../../core/gemini-stream.js'; -import { StreamingState } from '../../core/gemini-stream.js'; +import { processGeminiStream , StreamingState } from '../../core/gemini-stream.js'; const addHistoryItem = ( setHistory: React.Dispatch>, diff --git a/packages/cli/src/ui/utils/MarkdownRenderer.tsx b/packages/cli/src/ui/utils/MarkdownRenderer.tsx index 20b50939..ffe1ea46 100644 --- a/packages/cli/src/ui/utils/MarkdownRenderer.tsx +++ b/packages/cli/src/ui/utils/MarkdownRenderer.tsx @@ -197,7 +197,7 @@ export class MarkdownRenderer { * @param text The full markdown string to render. * @returns An array of React nodes representing markdown blocks. */ - public static render(text: string): React.ReactNode[] { + static render(text: string): React.ReactNode[] { if (!text) return []; const lines = text.split('\n'); diff --git a/packages/cli/src/utils/BackgroundTerminalAnalyzer.ts b/packages/cli/src/utils/BackgroundTerminalAnalyzer.ts index 3e958d09..6028f9b1 100644 --- a/packages/cli/src/utils/BackgroundTerminalAnalyzer.ts +++ b/packages/cli/src/utils/BackgroundTerminalAnalyzer.ts @@ -75,7 +75,7 @@ export class BackgroundTerminalAnalyzer { * @param command The command string that was executed (for context in prompts). * @returns A promise resolving to the final analysis outcome. */ - public async analyze( + async analyze( pid: ProcessHandle, tempStdoutFilePath: string, tempStderrFilePath: string, @@ -91,8 +91,8 @@ export class BackgroundTerminalAnalyzer { while (attempts < this.maxAttempts) { attempts++; - let currentStdout: string = ''; - let currentStderr: string = ''; + let currentStdout = ''; + let currentStderr = ''; // --- Robust File Reading --- try { diff --git a/packages/cli/src/utils/getFolderStructure.ts b/packages/cli/src/utils/getFolderStructure.ts index 5c26f400..d1e780a8 100644 --- a/packages/cli/src/utils/getFolderStructure.ts +++ b/packages/cli/src/utils/getFolderStructure.ts @@ -61,7 +61,7 @@ async function readFullStructure( const name = path.basename(folderPath); // Initialize with isIgnored: false const folderInfo: Omit = { - name: name, + name, path: folderPath, files: [], subFolders: [],