diff --git a/package.json b/package.json index d7c3de86ed3..2e83a1cfe2a 100644 --- a/package.json +++ b/package.json @@ -364,7 +364,7 @@ "install-webview": "cd webview-ui && npm install", "install-e2e": "cd e2e && npm install", "lint": "npm-run-all -l -p lint:*", - "lint:extension": "eslint src/**/*.ts", + "lint:extension": "eslint src --ext .ts", "lint:webview": "cd webview-ui && npm run lint", "lint:e2e": "cd e2e && npm run lint", "check-types": "npm-run-all -l -p check-types:*", diff --git a/src/__mocks__/fs/promises.ts b/src/__mocks__/fs/promises.ts index b037cd24573..e375649c786 100644 --- a/src/__mocks__/fs/promises.ts +++ b/src/__mocks__/fs/promises.ts @@ -24,26 +24,6 @@ const baseTestDirs = [ "/test/log/path", ] -// Helper function to format instructions -const formatInstructions = (sections: string[]): string => { - const joinedSections = sections.filter(Boolean).join("\n\n") - return joinedSections - ? ` -==== - -USER'S CUSTOM INSTRUCTIONS - -The following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the TOOL USE guidelines. - -${joinedSections}` - : "" -} - -// Helper function to format rule content -const formatRuleContent = (ruleFile: string, content: string): string => { - return `Rules:\n# Rules from ${ruleFile}:\n${content}` -} - type RuleFiles = { ".clinerules-code": string ".clinerules-ask": string @@ -65,7 +45,7 @@ const ensureDirectoryExists = (path: string) => { } const mockFs = { - readFile: jest.fn().mockImplementation(async (filePath: string, encoding?: string) => { + readFile: jest.fn().mockImplementation(async (filePath: string, _encoding?: string) => { // Return stored content if it exists if (mockFiles.has(filePath)) { return mockFiles.get(filePath) diff --git a/src/__mocks__/services/ripgrep/index.ts b/src/__mocks__/services/ripgrep/index.ts index f24adcb18dd..079b77d8316 100644 --- a/src/__mocks__/services/ripgrep/index.ts +++ b/src/__mocks__/services/ripgrep/index.ts @@ -13,7 +13,7 @@ * @param vscodeAppRoot - Optional VSCode app root path (can be undefined) * @returns Promise resolving to a mock path to the ripgrep binary */ -export const getBinPath = jest.fn().mockImplementation(async (vscodeAppRoot?: string): Promise => { +export const getBinPath = jest.fn().mockImplementation(async (_vscodeAppRoot?: string): Promise => { return "/mock/path/to/rg" }) @@ -30,7 +30,7 @@ export const getBinPath = jest.fn().mockImplementation(async (vscodeAppRoot?: st export const regexSearchFiles = jest .fn() .mockImplementation( - async (cwd?: string, directoryPath?: string, regex?: string, filePattern?: string): Promise => { + async (_cwd?: string, _directoryPath?: string, _regex?: string, _filePattern?: string): Promise => { return "Mock search results" }, ) @@ -43,6 +43,6 @@ export const regexSearchFiles = jest * @param maxLength - Optional maximum length (can be undefined) * @returns The original line or empty string if undefined */ -export const truncateLine = jest.fn().mockImplementation((line?: string, maxLength?: number): string => { +export const truncateLine = jest.fn().mockImplementation((line?: string, _maxLength?: number): string => { return line || "" }) diff --git a/src/api/index.ts b/src/api/index.ts index 10a959b548c..0e207335f39 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -77,7 +77,7 @@ export function buildApiHandler(configuration: ApiConfiguration): ApiHandler { case "requesty": return new RequestyHandler(options) case "human-relay": - return new HumanRelayHandler(options) + return new HumanRelayHandler() case "fake-ai": return new FakeAIHandler(options) case "xai": diff --git a/src/api/providers/__tests__/bedrock-custom-arn.test.ts b/src/api/providers/__tests__/bedrock-custom-arn.test.ts index 8b2d4c48d57..ebec24044f0 100644 --- a/src/api/providers/__tests__/bedrock-custom-arn.test.ts +++ b/src/api/providers/__tests__/bedrock-custom-arn.test.ts @@ -1,3 +1,5 @@ +// npx jest src/api/providers/__tests__/bedrock-custom-arn.test.ts + import { AwsBedrockHandler } from "../bedrock" import { ApiHandlerOptions } from "../../../shared/api" import { logger } from "../../../utils/logging" @@ -52,9 +54,6 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => { } }) -// Get mock module for testing -const bedrockMock = jest.requireMock("@aws-sdk/client-bedrock-runtime").__mock - describe("Bedrock ARN Handling", () => { // Helper function to create a handler with specific options const createHandler = (options: Partial = {}) => { @@ -236,7 +235,8 @@ describe("Bedrock ARN Handling", () => { // Create handler with ARN region different from provided region const arn = "arn:aws:bedrock:eu-west-1:123456789012:inference-profile/anthropic.claude-3-sonnet-20240229-v1:0" - const handler = createHandler({ + + createHandler({ awsCustomArn: arn, awsRegion: "us-east-1", // Different from ARN region }) diff --git a/src/api/providers/__tests__/bedrock-invokedModelId.test.ts b/src/api/providers/__tests__/bedrock-invokedModelId.test.ts index 5db6e955824..3e49ad0b952 100644 --- a/src/api/providers/__tests__/bedrock-invokedModelId.test.ts +++ b/src/api/providers/__tests__/bedrock-invokedModelId.test.ts @@ -1,3 +1,9 @@ +// npx jest src/api/providers/__tests__/bedrock-invokedModelId.test.ts + +import { ApiHandlerOptions } from "../../../shared/api" + +import { AwsBedrockHandler, StreamEvent } from "../bedrock" + // Mock AWS SDK credential providers and Bedrock client jest.mock("@aws-sdk/credential-providers", () => ({ fromIni: jest.fn().mockReturnValue({ @@ -62,11 +68,6 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => { } }) -import { AwsBedrockHandler, StreamEvent } from "../bedrock" -import { ApiHandlerOptions } from "../../../shared/api" -import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime" -const { fromIni } = require("@aws-sdk/credential-providers") - describe("AwsBedrockHandler with invokedModelId", () => { let mockSend: jest.Mock @@ -279,17 +280,6 @@ describe("AwsBedrockHandler with invokedModelId", () => { } }) - // Mock getModel to return expected values - const getModelSpy = jest.spyOn(handler, "getModel").mockReturnValue({ - id: "anthropic.claude-3-5-sonnet-20241022-v2:0", - info: { - maxTokens: 4096, - contextWindow: 128_000, - supportsPromptCache: false, - supportsImages: true, - }, - }) - // Create a message generator const messageGenerator = handler.createMessage("system prompt", [{ role: "user", content: "user message" }]) diff --git a/src/api/providers/__tests__/bedrock.test.ts b/src/api/providers/__tests__/bedrock.test.ts index fb81345ae52..bddb0626bb9 100644 --- a/src/api/providers/__tests__/bedrock.test.ts +++ b/src/api/providers/__tests__/bedrock.test.ts @@ -22,11 +22,8 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => ({ })) import { AwsBedrockHandler } from "../bedrock" -import { MessageContent } from "../../../shared/api" -import { BedrockRuntimeClient, ConverseStreamCommand } from "@aws-sdk/client-bedrock-runtime" + import { Anthropic } from "@anthropic-ai/sdk" -const { fromIni } = require("@aws-sdk/credential-providers") -import { logger } from "../../../utils/logging" describe("AwsBedrockHandler", () => { let handler: AwsBedrockHandler diff --git a/src/api/providers/__tests__/gemini.test.ts b/src/api/providers/__tests__/gemini.test.ts index c5679ccf7f8..af32b1bebbf 100644 --- a/src/api/providers/__tests__/gemini.test.ts +++ b/src/api/providers/__tests__/gemini.test.ts @@ -95,7 +95,7 @@ describe("GeminiHandler", () => { const stream = handler.createMessage(systemPrompt, mockMessages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should throw before yielding any chunks } }).rejects.toThrow() diff --git a/src/api/providers/__tests__/lmstudio.test.ts b/src/api/providers/__tests__/lmstudio.test.ts index 114f9938498..8667b273d12 100644 --- a/src/api/providers/__tests__/lmstudio.test.ts +++ b/src/api/providers/__tests__/lmstudio.test.ts @@ -1,7 +1,7 @@ +import { Anthropic } from "@anthropic-ai/sdk" + import { LmStudioHandler } from "../lmstudio" import { ApiHandlerOptions } from "../../../shared/api" -import OpenAI from "openai" -import { Anthropic } from "@anthropic-ai/sdk" // Mock OpenAI client const mockCreate = jest.fn() @@ -120,7 +120,7 @@ describe("LmStudioHandler", () => { const stream = handler.createMessage(systemPrompt, messages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should not reach here } }).rejects.toThrow("Please check the LM Studio developer logs to debug what went wrong") diff --git a/src/api/providers/__tests__/mistral.test.ts b/src/api/providers/__tests__/mistral.test.ts index 781cb3dcfc5..5578cec49e9 100644 --- a/src/api/providers/__tests__/mistral.test.ts +++ b/src/api/providers/__tests__/mistral.test.ts @@ -1,6 +1,7 @@ -import { MistralHandler } from "../mistral" -import { ApiHandlerOptions, mistralDefaultModelId } from "../../../shared/api" import { Anthropic } from "@anthropic-ai/sdk" + +import { MistralHandler } from "../mistral" +import { ApiHandlerOptions } from "../../../shared/api" import { ApiStreamTextChunk } from "../../transform/stream" // Mock Mistral client @@ -9,7 +10,7 @@ jest.mock("@mistralai/mistralai", () => { return { Mistral: jest.fn().mockImplementation(() => ({ chat: { - stream: mockCreate.mockImplementation(async (options) => { + stream: mockCreate.mockImplementation(async (_options) => { const stream = { [Symbol.asyncIterator]: async function* () { yield { diff --git a/src/api/providers/__tests__/ollama.test.ts b/src/api/providers/__tests__/ollama.test.ts index a0fc0093ab3..91b14684212 100644 --- a/src/api/providers/__tests__/ollama.test.ts +++ b/src/api/providers/__tests__/ollama.test.ts @@ -1,7 +1,7 @@ +import { Anthropic } from "@anthropic-ai/sdk" + import { OllamaHandler } from "../ollama" import { ApiHandlerOptions } from "../../../shared/api" -import OpenAI from "openai" -import { Anthropic } from "@anthropic-ai/sdk" // Mock OpenAI client const mockCreate = jest.fn() @@ -120,7 +120,7 @@ describe("OllamaHandler", () => { const stream = handler.createMessage(systemPrompt, messages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should not reach here } }).rejects.toThrow("API Error") diff --git a/src/api/providers/__tests__/openai-native.test.ts b/src/api/providers/__tests__/openai-native.test.ts index ce5fb6c8a67..68ab0f5a5fa 100644 --- a/src/api/providers/__tests__/openai-native.test.ts +++ b/src/api/providers/__tests__/openai-native.test.ts @@ -1,7 +1,7 @@ +import { Anthropic } from "@anthropic-ai/sdk" + import { OpenAiNativeHandler } from "../openai-native" import { ApiHandlerOptions } from "../../../shared/api" -import OpenAI from "openai" -import { Anthropic } from "@anthropic-ai/sdk" // Mock OpenAI client const mockCreate = jest.fn() @@ -116,7 +116,7 @@ describe("OpenAiNativeHandler", () => { mockCreate.mockRejectedValueOnce(new Error("API Error")) const stream = handler.createMessage(systemPrompt, messages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should not reach here } }).rejects.toThrow("API Error") diff --git a/src/api/providers/__tests__/openai.test.ts b/src/api/providers/__tests__/openai.test.ts index 5d8c92f80b2..17da968ae61 100644 --- a/src/api/providers/__tests__/openai.test.ts +++ b/src/api/providers/__tests__/openai.test.ts @@ -176,7 +176,7 @@ describe("OpenAiHandler", () => { const stream = handler.createMessage("system prompt", testMessages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should not reach here } }).rejects.toThrow("API Error") @@ -191,7 +191,7 @@ describe("OpenAiHandler", () => { const stream = handler.createMessage("system prompt", testMessages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should not reach here } }).rejects.toThrow("Rate limit exceeded") diff --git a/src/api/providers/__tests__/requesty.test.ts b/src/api/providers/__tests__/requesty.test.ts index 53dda2637ec..dfb00586577 100644 --- a/src/api/providers/__tests__/requesty.test.ts +++ b/src/api/providers/__tests__/requesty.test.ts @@ -1,6 +1,6 @@ import { Anthropic } from "@anthropic-ai/sdk" import OpenAI from "openai" -import { ApiHandlerOptions, ModelInfo, requestyDefaultModelInfo } from "../../../shared/api" +import { ApiHandlerOptions, ModelInfo } from "../../../shared/api" import { RequestyHandler } from "../requesty" import { convertToOpenAiMessages } from "../../transform/openai-format" import { convertToR1Format } from "../../transform/r1-format" @@ -40,9 +40,7 @@ describe("RequestyHandler", () => { jest.clearAllMocks() // Setup mock create function that preserves params - let lastParams: any - mockCreate = jest.fn().mockImplementation((params) => { - lastParams = params + mockCreate = jest.fn().mockImplementation((_params) => { return { [Symbol.asyncIterator]: async function* () { yield { diff --git a/src/api/providers/__tests__/vertex.test.ts b/src/api/providers/__tests__/vertex.test.ts index 6c4e891d0b7..3af1e3c70fe 100644 --- a/src/api/providers/__tests__/vertex.test.ts +++ b/src/api/providers/__tests__/vertex.test.ts @@ -2,7 +2,6 @@ import { Anthropic } from "@anthropic-ai/sdk" import { AnthropicVertex } from "@anthropic-ai/vertex-sdk" -import { BetaThinkingConfigParam } from "@anthropic-ai/sdk/resources/beta" import { VertexHandler } from "../vertex" import { ApiStreamChunk } from "../../transform/stream" @@ -388,7 +387,7 @@ describe("VertexHandler", () => { const stream = handler.createMessage(systemPrompt, mockMessages) await expect(async () => { - for await (const chunk of stream) { + for await (const _chunk of stream) { // Should throw before yielding any chunks } }).rejects.toThrow("Vertex API error") diff --git a/src/api/providers/__tests__/vscode-lm.test.ts b/src/api/providers/__tests__/vscode-lm.test.ts index d7e674d0450..59d49f764e7 100644 --- a/src/api/providers/__tests__/vscode-lm.test.ts +++ b/src/api/providers/__tests__/vscode-lm.test.ts @@ -21,7 +21,7 @@ jest.mock("vscode", () => { return { workspace: { - onDidChangeConfiguration: jest.fn((callback) => ({ + onDidChangeConfiguration: jest.fn((_callback) => ({ dispose: jest.fn(), })), }, diff --git a/src/api/providers/bedrock.ts b/src/api/providers/bedrock.ts index 116e2822dd5..b388748440f 100644 --- a/src/api/providers/bedrock.ts +++ b/src/api/providers/bedrock.ts @@ -603,8 +603,8 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH // Look for a pattern where the first segment before a dot doesn't contain dots or colons // and the remaining parts still contain at least one dot const genericPrefixMatch = modelId.match(/^([^.:]+)\.(.+\..+)$/) + if (genericPrefixMatch) { - const genericPrefix = genericPrefixMatch[1] + "." return genericPrefixMatch[2] } } @@ -708,10 +708,11 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH if (Array.isArray(content)) { return content.map((block) => { // Use destructuring to remove cachePoint property - const { cachePoint, ...rest } = block + const { cachePoint: _, ...rest } = block return rest }) } + return content } @@ -864,7 +865,7 @@ Suggestions: /** * Formats an error message based on the error type and context */ - private formatErrorMessage(error: unknown, errorType: string, isStreamContext: boolean): string { + private formatErrorMessage(error: unknown, errorType: string, _isStreamContext: boolean): string { const definition = AwsBedrockHandler.ERROR_TYPES[errorType] || AwsBedrockHandler.ERROR_TYPES.GENERIC let template = definition.messageTemplate diff --git a/src/api/providers/gemini.ts b/src/api/providers/gemini.ts index 94e5610adb2..777b9ee9158 100644 --- a/src/api/providers/gemini.ts +++ b/src/api/providers/gemini.ts @@ -4,7 +4,6 @@ import { type GenerateContentResponseUsageMetadata, type GenerateContentParameters, type Content, - CreateCachedContentConfig, } from "@google/genai" import NodeCache from "node-cache" diff --git a/src/api/providers/human-relay.ts b/src/api/providers/human-relay.ts index b8bd4c28298..ecc29c8e7d3 100644 --- a/src/api/providers/human-relay.ts +++ b/src/api/providers/human-relay.ts @@ -1,23 +1,16 @@ -// filepath: e:\Project\Roo-Code\src\api\providers\human-relay.ts import { Anthropic } from "@anthropic-ai/sdk" -import { ApiHandlerOptions, ModelInfo } from "../../shared/api" +import * as vscode from "vscode" + +import { ModelInfo } from "../../shared/api" import { ApiHandler, SingleCompletionHandler } from "../index" import { ApiStream } from "../transform/stream" -import * as vscode from "vscode" -import { ExtensionMessage } from "../../shared/ExtensionMessage" -import { getPanel } from "../../activate/registerCommands" // Import the getPanel function /** * Human Relay API processor * This processor does not directly call the API, but interacts with the model through human operations copy and paste. */ export class HumanRelayHandler implements ApiHandler, SingleCompletionHandler { - private options: ApiHandlerOptions - - constructor(options: ApiHandlerOptions) { - this.options = options - } - countTokens(content: Array): Promise { + countTokens(_content: Array): Promise { return Promise.resolve(0) } @@ -125,15 +118,10 @@ async function showHumanRelayDialog(promptText: string): Promise { - resolve(response) - }, + (response: string | undefined) => resolve(response), ) // Open the dialog box directly using the current panel - vscode.commands.executeCommand("roo-cline.showHumanRelayDialog", { - requestId, - promptText, - }) + vscode.commands.executeCommand("roo-cline.showHumanRelayDialog", { requestId, promptText }) }) } diff --git a/src/api/providers/mistral.ts b/src/api/providers/mistral.ts index 38f753c2610..4daaa2ab855 100644 --- a/src/api/providers/mistral.ts +++ b/src/api/providers/mistral.ts @@ -1,16 +1,7 @@ import { Anthropic } from "@anthropic-ai/sdk" import { Mistral } from "@mistralai/mistralai" import { SingleCompletionHandler } from "../" -import { - ApiHandlerOptions, - mistralDefaultModelId, - MistralModelId, - mistralModels, - ModelInfo, - openAiNativeDefaultModelId, - OpenAiNativeModelId, - openAiNativeModels, -} from "../../shared/api" +import { ApiHandlerOptions, mistralDefaultModelId, MistralModelId, mistralModels, ModelInfo } from "../../shared/api" import { convertToMistralMessages } from "../transform/mistral-format" import { ApiStream } from "../transform/stream" import { BaseProvider } from "./base-provider" diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index 71568dfde1e..10cc5e40cd4 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -226,7 +226,7 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl } } - protected processUsageMetrics(usage: any, modelInfo?: ModelInfo): ApiStreamUsageChunk { + protected processUsageMetrics(usage: any, _modelInfo?: ModelInfo): ApiStreamUsageChunk { return { type: "usage", inputTokens: usage?.prompt_tokens || 0, diff --git a/src/api/providers/vertex.ts b/src/api/providers/vertex.ts index 1f863c57cdb..865e588de58 100644 --- a/src/api/providers/vertex.ts +++ b/src/api/providers/vertex.ts @@ -57,15 +57,6 @@ interface VertexMessage extends Omit content: string | VertexContentBlock[] } -interface VertexMessageCreateParams { - model: string - max_tokens: number - temperature: number - system: string | VertexTextBlock[] - messages: VertexMessage[] - stream: boolean -} - interface VertexMessageResponse { content: Array<{ type: "text"; text: string }> } @@ -259,7 +250,7 @@ export class VertexHandler extends BaseProvider implements SingleCompletionHandl private async *createClaudeMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream { const model = this.getModel() - let { id, info, temperature, maxTokens, thinking } = model + let { id, temperature, maxTokens, thinking } = model const useCache = model.info.supportsPromptCache // Find indices of user messages that we want to cache diff --git a/src/api/providers/vscode-lm.ts b/src/api/providers/vscode-lm.ts index f3d21884b3a..85a17cc2654 100644 --- a/src/api/providers/vscode-lm.ts +++ b/src/api/providers/vscode-lm.ts @@ -122,7 +122,7 @@ export class VsCodeLmHandler extends BaseProvider implements SingleCompletionHan family: "lm", version: "1.0", maxInputTokens: 8192, - sendRequest: async (messages, options, token) => { + sendRequest: async (_messages, _options, _token) => { // Provide a minimal implementation return { stream: (async function* () { diff --git a/src/api/transform/cache-strategy/__tests__/cache-strategy.test.ts b/src/api/transform/cache-strategy/__tests__/cache-strategy.test.ts index 83729a7aa04..6a490aac2c1 100644 --- a/src/api/transform/cache-strategy/__tests__/cache-strategy.test.ts +++ b/src/api/transform/cache-strategy/__tests__/cache-strategy.test.ts @@ -1,10 +1,10 @@ -import { MultiPointStrategy } from "../multi-point-strategy" -import { CacheStrategy } from "../base-strategy" -import { CacheStrategyConfig, ModelInfo, CachePointPlacement } from "../types" import { ContentBlock, SystemContentBlock } from "@aws-sdk/client-bedrock-runtime" import { Anthropic } from "@anthropic-ai/sdk" +import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime" + +import { MultiPointStrategy } from "../multi-point-strategy" +import { CacheStrategyConfig, ModelInfo, CachePointPlacement } from "../types" import { AwsBedrockHandler } from "../../../providers/bedrock" -import { BedrockRuntimeClient, ConverseStreamCommand } from "@aws-sdk/client-bedrock-runtime" // Common test utilities const defaultModelInfo: ModelInfo = { @@ -363,7 +363,7 @@ describe("Cache Strategy", () => { // Call the method that uses convertToBedrockConverseMessages const stream = handler.createMessage(systemPrompt, mockMessages) - for await (const chunk of stream) { + for await (const _chunk of stream) { // Just consume the stream } @@ -404,7 +404,7 @@ describe("Cache Strategy", () => { // Call the method that uses convertToBedrockConverseMessages const stream = handler.createMessage(systemPrompt, mockMessages) - for await (const chunk of stream) { + for await (const _chunk of stream) { // Just consume the stream } @@ -505,7 +505,7 @@ describe("Cache Strategy", () => { // Call the method that uses convertToBedrockConverseMessages const stream = handler.createMessage(systemPrompt, mockMessages) - for await (const chunk of stream) { + for await (const _chunk of stream) { // Just consume the stream } @@ -555,7 +555,7 @@ describe("Cache Strategy", () => { // Call the method that uses convertToBedrockConverseMessages const stream = handler.createMessage(systemPrompt, mockMessages) - for await (const chunk of stream) { + for await (const _chunk of stream) { // Just consume the stream } @@ -931,7 +931,7 @@ describe("Cache Strategy", () => { // (260 tokens from messages 7-8 plus 400 tokens from the new messages) // Create messages matching Example 5 from documentation - const messages = [ + const _messages = [ createMessage("user", "Tell me about machine learning.", 100), createMessage("assistant", "Machine learning is a field of study...", 200), createMessage("user", "What about deep learning?", 100), @@ -948,7 +948,7 @@ describe("Cache Strategy", () => { ] // Previous cache point placements from Example 4 - const previousCachePointPlacements: CachePointPlacement[] = [ + const _previousCachePointPlacements: CachePointPlacement[] = [ { index: 2, // After the second user message type: "message", diff --git a/src/api/transform/cache-strategy/base-strategy.ts b/src/api/transform/cache-strategy/base-strategy.ts index 987e28431db..1bc05cdb843 100644 --- a/src/api/transform/cache-strategy/base-strategy.ts +++ b/src/api/transform/cache-strategy/base-strategy.ts @@ -1,7 +1,6 @@ import { Anthropic } from "@anthropic-ai/sdk" import { ContentBlock, SystemContentBlock, Message, ConversationRole } from "@aws-sdk/client-bedrock-runtime" import { CacheStrategyConfig, CacheResult, CachePointPlacement } from "./types" -import { logger } from "../../../utils/logging" export abstract class CacheStrategy { /** diff --git a/src/api/transform/cache-strategy/multi-point-strategy.ts b/src/api/transform/cache-strategy/multi-point-strategy.ts index aa5ae37f343..dc82136997c 100644 --- a/src/api/transform/cache-strategy/multi-point-strategy.ts +++ b/src/api/transform/cache-strategy/multi-point-strategy.ts @@ -95,9 +95,6 @@ export class MultiPointStrategy extends CacheStrategy { return placements } - // Calculate total tokens in the conversation - const totalTokens = this.config.messages.reduce((acc, curr) => acc + this.estimateTokenCount(curr), 0) - // Calculate tokens in new messages (added since last cache point placement) const lastPreviousIndex = previousPlacements[previousPlacements.length - 1].index const newMessagesTokens = this.config.messages @@ -181,7 +178,6 @@ export class MultiPointStrategy extends CacheStrategy { } else if (i === smallestGapIndex) { // Replace with a combined placement const combinedEndIndex = previousPlacements[i + 1].index - const combinedTokens = tokensBetweenPlacements[i] + tokensBetweenPlacements[i + 1] // Find the optimal placement within this combined range const startOfRange = i === 0 ? 0 : previousPlacements[i - 1].index + 1 diff --git a/src/api/transform/mistral-format.ts b/src/api/transform/mistral-format.ts index baf81ef24d2..3f9487a9980 100644 --- a/src/api/transform/mistral-format.ts +++ b/src/api/transform/mistral-format.ts @@ -21,7 +21,7 @@ export function convertToMistralMessages(anthropicMessages: Anthropic.Messages.M }) } else { if (anthropicMessage.role === "user") { - const { nonToolMessages, toolMessages } = anthropicMessage.content.reduce<{ + const { nonToolMessages } = anthropicMessage.content.reduce<{ nonToolMessages: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] toolMessages: Anthropic.ToolResultBlockParam[] }>( @@ -53,7 +53,7 @@ export function convertToMistralMessages(anthropicMessages: Anthropic.Messages.M }) } } else if (anthropicMessage.role === "assistant") { - const { nonToolMessages, toolMessages } = anthropicMessage.content.reduce<{ + const { nonToolMessages } = anthropicMessage.content.reduce<{ nonToolMessages: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] toolMessages: Anthropic.ToolUseBlockParam[] }>( diff --git a/src/core/__tests__/Cline.test.ts b/src/core/__tests__/Cline.test.ts index e12078d3525..d407e10454b 100644 --- a/src/core/__tests__/Cline.test.ts +++ b/src/core/__tests__/Cline.test.ts @@ -191,19 +191,19 @@ describe("Cline", () => { return undefined }), - update: jest.fn().mockImplementation((key, value) => Promise.resolve()), + update: jest.fn().mockImplementation((_key, _value) => Promise.resolve()), keys: jest.fn().mockReturnValue([]), }, globalStorageUri: storageUri, workspaceState: { - get: jest.fn().mockImplementation((key) => undefined), - update: jest.fn().mockImplementation((key, value) => Promise.resolve()), + get: jest.fn().mockImplementation((_key) => undefined), + update: jest.fn().mockImplementation((_key, _value) => Promise.resolve()), keys: jest.fn().mockReturnValue([]), }, secrets: { - get: jest.fn().mockImplementation((key) => Promise.resolve(undefined)), - store: jest.fn().mockImplementation((key, value) => Promise.resolve()), - delete: jest.fn().mockImplementation((key) => Promise.resolve()), + get: jest.fn().mockImplementation((_key) => Promise.resolve(undefined)), + store: jest.fn().mockImplementation((_key, _value) => Promise.resolve()), + delete: jest.fn().mockImplementation((_key) => Promise.resolve()), }, extensionUri: { fsPath: "/mock/extension/path", @@ -385,7 +385,7 @@ describe("Cline", () => { // Mock the method with a stable implementation jest.spyOn(Cline.prototype, "getEnvironmentDetails").mockImplementation( // Use 'any' type to allow for dynamic test properties - async function (this: any, verbose: boolean = false): Promise { + async function (this: any, _verbose: boolean = false): Promise { // Use test-specific mock if available if (this._mockGetEnvironmentDetails) { return this._mockGetEnvironmentDetails() diff --git a/src/core/__tests__/mode-validator.test.ts b/src/core/__tests__/mode-validator.test.ts index 72c08d00286..1111f24b9f2 100644 --- a/src/core/__tests__/mode-validator.test.ts +++ b/src/core/__tests__/mode-validator.test.ts @@ -1,6 +1,6 @@ // npx jest src/core/__tests__/mode-validator.test.ts -import { isToolAllowedForMode, getModeConfig, modes, ModeConfig } from "../../shared/modes" +import { isToolAllowedForMode, modes, ModeConfig } from "../../shared/modes" import { TOOL_GROUPS } from "../../shared/tools" import { validateToolUse } from "../mode-validator" @@ -10,7 +10,6 @@ describe("mode-validator", () => { describe("isToolAllowedForMode", () => { describe("code mode", () => { it("allows all code mode tools", () => { - const mode = getModeConfig(codeMode) // Code mode has all groups Object.entries(TOOL_GROUPS).forEach(([_, config]) => { config.tools.forEach((tool: string) => { @@ -26,7 +25,6 @@ describe("mode-validator", () => { describe("architect mode", () => { it("allows configured tools", () => { - const mode = getModeConfig(architectMode) // Architect mode has read, browser, and mcp groups const architectTools = [ ...TOOL_GROUPS.read.tools, @@ -41,7 +39,6 @@ describe("mode-validator", () => { describe("ask mode", () => { it("allows configured tools", () => { - const mode = getModeConfig(askMode) // Ask mode has read, browser, and mcp groups const askTools = [...TOOL_GROUPS.read.tools, ...TOOL_GROUPS.browser.tools, ...TOOL_GROUPS.mcp.tools] askTools.forEach((tool) => { diff --git a/src/core/__tests__/read-file-maxReadFileLine.test.ts b/src/core/__tests__/read-file-maxReadFileLine.test.ts index e3b0a8f67bf..f8508694549 100644 --- a/src/core/__tests__/read-file-maxReadFileLine.test.ts +++ b/src/core/__tests__/read-file-maxReadFileLine.test.ts @@ -8,7 +8,6 @@ import { extractTextFromFile } from "../../integrations/misc/extract-text" import { parseSourceCodeDefinitionsForFile } from "../../services/tree-sitter" import { isBinaryFile } from "isbinaryfile" import { ReadFileToolUse } from "../../shared/tools" -import { ToolUsage } from "../../schemas" // Mock dependencies jest.mock("../../integrations/misc/line-counter") @@ -100,7 +99,7 @@ describe("read_file tool with maxReadFileLine setting", () => { mockInputContent = fileContent // Setup the extractTextFromFile mock implementation with the current mockInputContent - mockedExtractTextFromFile.mockImplementation((filePath) => { + mockedExtractTextFromFile.mockImplementation((_filePath) => { const actual = jest.requireActual("../../integrations/misc/extract-text") return Promise.resolve(actual.addLineNumbers(mockInputContent)) }) diff --git a/src/core/__tests__/read-file-xml.test.ts b/src/core/__tests__/read-file-xml.test.ts index 1e63bb1446f..1228750a7df 100644 --- a/src/core/__tests__/read-file-xml.test.ts +++ b/src/core/__tests__/read-file-xml.test.ts @@ -8,7 +8,6 @@ import { extractTextFromFile } from "../../integrations/misc/extract-text" import { parseSourceCodeDefinitionsForFile } from "../../services/tree-sitter" import { isBinaryFile } from "isbinaryfile" import { ReadFileToolUse } from "../../shared/tools" -import { ToolUsage } from "../../schemas" // Mock dependencies jest.mock("../../integrations/misc/line-counter") @@ -22,7 +21,7 @@ jest.mock("../../integrations/misc/extract-text", () => { ...actual, // Expose the spy so tests can access it __addLineNumbersSpy: addLineNumbersSpy, - extractTextFromFile: jest.fn().mockImplementation((filePath) => { + extractTextFromFile: jest.fn().mockImplementation((_filePath) => { // Use the actual addLineNumbers function const content = mockInputContent return Promise.resolve(actual.addLineNumbers(content)) diff --git a/src/core/config/ProviderSettingsManager.ts b/src/core/config/ProviderSettingsManager.ts index 9956c4b0953..7df34e7844a 100644 --- a/src/core/config/ProviderSettingsManager.ts +++ b/src/core/config/ProviderSettingsManager.ts @@ -1,7 +1,7 @@ import { ExtensionContext } from "vscode" import { z, ZodError } from "zod" -import { providerSettingsSchema, ApiConfigMeta, ProviderSettings } from "../../schemas" +import { providerSettingsSchema, ApiConfigMeta } from "../../schemas" import { Mode, modes } from "../../shared/modes" import { telemetryService } from "../../services/telemetry/TelemetryService" @@ -78,7 +78,7 @@ export class ProviderSettingsManager { let isDirty = false // Ensure all configs have IDs. - for (const [name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) { + for (const [_name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) { if (!apiConfig.id) { apiConfig.id = this.generateId() isDirty = true @@ -130,7 +130,7 @@ export class ProviderSettingsManager { rateLimitSeconds = 0 } - for (const [name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) { + for (const [_name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) { if (apiConfig.rateLimitSeconds === undefined) { apiConfig.rateLimitSeconds = rateLimitSeconds } @@ -162,7 +162,7 @@ export class ProviderSettingsManager { fuzzyMatchThreshold = 1.0 } - for (const [name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) { + for (const [_name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) { if (apiConfig.diffEnabled === undefined) { apiConfig.diffEnabled = diffEnabled } diff --git a/src/core/config/__tests__/CustomModesManager.test.ts b/src/core/config/__tests__/CustomModesManager.test.ts index 3af26c92b80..a5de1414835 100644 --- a/src/core/config/__tests__/CustomModesManager.test.ts +++ b/src/core/config/__tests__/CustomModesManager.test.ts @@ -170,7 +170,7 @@ describe("CustomModesManager", () => { throw new Error("File not found") }) ;(fs.writeFile as jest.Mock).mockImplementation( - async (path: string, content: string, encoding?: string) => { + async (path: string, content: string, _encoding?: string) => { if (path === mockSettingsPath) { settingsContent = JSON.parse(content) } @@ -297,7 +297,7 @@ describe("CustomModesManager", () => { throw new Error("File not found") }) ;(fs.writeFile as jest.Mock).mockImplementation( - async (path: string, content: string, encoding?: string) => { + async (path: string, content: string, _encoding?: string) => { if (path === mockSettingsPath) { settingsContent = JSON.parse(content) } diff --git a/src/core/diff/strategies/multi-search-replace.ts b/src/core/diff/strategies/multi-search-replace.ts index 00cebd2bead..7c07f06ba0b 100644 --- a/src/core/diff/strategies/multi-search-replace.ts +++ b/src/core/diff/strategies/multi-search-replace.ts @@ -203,7 +203,7 @@ Only use a single line of '=======' between search and replacement content, beca const SEARCH_PREFIX = "<<<<<<<" const REPLACE_PREFIX = ">>>>>>>" - const reportMergeConflictError = (found: string, expected: string) => ({ + const reportMergeConflictError = (found: string, _expected: string) => ({ success: false, error: `ERROR: Special marker '${found}' found in your diff content at line ${state.line}:\n` + @@ -525,7 +525,7 @@ Only use a single line of '=======' between search and replacement content, beca }) // Apply the replacement while preserving exact indentation - const indentedReplaceLines = replaceLines.map((line, i) => { + const indentedReplaceLines = replaceLines.map((line) => { // Get the matched line's exact indentation const matchedIndent = originalIndents[0] || "" diff --git a/src/core/ignore/__mocks__/RooIgnoreController.ts b/src/core/ignore/__mocks__/RooIgnoreController.ts index 7060b5ea667..45ac23aacbe 100644 --- a/src/core/ignore/__mocks__/RooIgnoreController.ts +++ b/src/core/ignore/__mocks__/RooIgnoreController.ts @@ -3,7 +3,7 @@ export const LOCK_TEXT_SYMBOL = "\u{1F512}" export class RooIgnoreController { rooIgnoreContent: string | undefined = undefined - constructor(cwd: string) { + constructor(_cwd: string) { // No-op constructor } @@ -12,12 +12,12 @@ export class RooIgnoreController { return Promise.resolve() } - validateAccess(filePath: string): boolean { + validateAccess(_filePath: string): boolean { // Default implementation: allow all access return true } - validateCommand(command: string): string | undefined { + validateCommand(_command: string): string | undefined { // Default implementation: allow all commands return undefined } diff --git a/src/core/ignore/__tests__/RooIgnoreController.security.test.ts b/src/core/ignore/__tests__/RooIgnoreController.security.test.ts index 3bb4f467709..c71c1fcdb6f 100644 --- a/src/core/ignore/__tests__/RooIgnoreController.security.test.ts +++ b/src/core/ignore/__tests__/RooIgnoreController.security.test.ts @@ -4,7 +4,6 @@ import { RooIgnoreController } from "../RooIgnoreController" import * as path from "path" import * as fs from "fs/promises" import { fileExistsAtPath } from "../../../utils/fs" -import * as vscode from "vscode" // Mock dependencies jest.mock("fs/promises") diff --git a/src/core/ignore/__tests__/RooIgnoreController.test.ts b/src/core/ignore/__tests__/RooIgnoreController.test.ts index d8ae0a53d8e..1e5dbd50727 100644 --- a/src/core/ignore/__tests__/RooIgnoreController.test.ts +++ b/src/core/ignore/__tests__/RooIgnoreController.test.ts @@ -433,9 +433,6 @@ describe("RooIgnoreController", () => { mockFileExists.mockResolvedValue(true) mockReadFile.mockResolvedValue("node_modules") - // Find and trigger the onCreate handler - const onCreateHandler = mockWatcher.onDidCreate.mock.calls[0][0] - // Force reload of .rooignore content manually await controller.initialize() diff --git a/src/core/mentions/index.ts b/src/core/mentions/index.ts index 592ff8fe87e..73b4e71613f 100644 --- a/src/core/mentions/index.ts +++ b/src/core/mentions/index.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode" import * as path from "path" import { openFile } from "../../integrations/misc/open-file" import { UrlContentFetcher } from "../../services/browser/UrlContentFetcher" -import { mentionRegexGlobal, formatGitSuggestion, type MentionSuggestion } from "../../shared/context-mentions" +import { mentionRegexGlobal } from "../../shared/context-mentions" import fs from "fs/promises" import { extractTextFromFile } from "../../integrations/misc/extract-text" import { isBinaryFile } from "isbinaryfile" diff --git a/src/core/prompts/__tests__/sections.test.ts b/src/core/prompts/__tests__/sections.test.ts index 525db3ffc3f..d6515883c8b 100644 --- a/src/core/prompts/__tests__/sections.test.ts +++ b/src/core/prompts/__tests__/sections.test.ts @@ -35,7 +35,7 @@ describe("getCapabilitiesSection", () => { const mockDiffStrategy: DiffStrategy = { getName: () => "MockStrategy", getToolDescription: () => "apply_diff tool description", - applyDiff: async (originalContent: string, diffContent: string): Promise => { + applyDiff: async (_originalContent: string, _diffContent: string): Promise => { return { success: true, content: "mock result" } }, } diff --git a/src/core/prompts/__tests__/system.test.ts b/src/core/prompts/__tests__/system.test.ts index d0dda37e2dd..7f480dd69d7 100644 --- a/src/core/prompts/__tests__/system.test.ts +++ b/src/core/prompts/__tests__/system.test.ts @@ -2,11 +2,9 @@ import * as vscode from "vscode" import { SYSTEM_PROMPT } from "../system" import { McpHub } from "../../../services/mcp/McpHub" -import { ClineProvider } from "../../../core/webview/ClineProvider" import { defaultModeSlug, modes, Mode, ModeConfig } from "../../../shared/modes" import "../../../utils/path" // Import path utils to get access to toPosix string extension. import { addCustomInstructions } from "../sections/custom-instructions" -import { EXPERIMENT_IDS } from "../../../shared/experiments" import { MultiSearchReplaceDiffStrategy } from "../../diff/strategies/multi-search-replace" // Mock the sections @@ -119,14 +117,6 @@ const mockContext = { }, } as unknown as vscode.ExtensionContext -// Create a minimal mock of ClineProvider -const mockProvider = { - ensureMcpServersDirectoryExists: async () => "/mock/mcp/path", - ensureSettingsDirectoryExists: async () => "/mock/settings/path", - postMessageToWebview: async () => {}, - context: mockContext, -} as unknown as ClineProvider - // Instead of extending McpHub, create a mock that implements just what we need const createMockMcpHub = (): McpHub => ({ @@ -481,7 +471,6 @@ describe("SYSTEM_PROMPT", () => { }) describe("addCustomInstructions", () => { - let experiments: Record | undefined beforeAll(() => { // Ensure fs mock is properly initialized const mockFs = jest.requireMock("fs/promises") @@ -493,9 +482,6 @@ describe("addCustomInstructions", () => { } throw new Error(`ENOENT: no such file or directory, mkdir '${path}'`) }) - - // Initialize experiments as undefined by default - experiments = undefined }) beforeEach(() => { diff --git a/src/core/prompts/instructions/create-mode.ts b/src/core/prompts/instructions/create-mode.ts index fd88dbfb596..2540b4feabd 100644 --- a/src/core/prompts/instructions/create-mode.ts +++ b/src/core/prompts/instructions/create-mode.ts @@ -1,6 +1,6 @@ import * as path from "path" import * as vscode from "vscode" -import { promises as fs } from "fs" + import { GlobalFileNames } from "../../../shared/globalFileNames" export async function createModeInstructions(context: vscode.ExtensionContext | undefined): Promise { diff --git a/src/core/prompts/sections/__tests__/custom-instructions.test.ts b/src/core/prompts/sections/__tests__/custom-instructions.test.ts index 77ccba07a04..e243526d210 100644 --- a/src/core/prompts/sections/__tests__/custom-instructions.test.ts +++ b/src/core/prompts/sections/__tests__/custom-instructions.test.ts @@ -1,8 +1,8 @@ -import { loadRuleFiles, addCustomInstructions } from "../custom-instructions" import fs from "fs/promises" -import path from "path" import { PathLike } from "fs" +import { loadRuleFiles, addCustomInstructions } from "../custom-instructions" + // Mock fs/promises jest.mock("fs/promises") @@ -134,7 +134,7 @@ describe("loadRuleFiles", () => { ] as any) statMock.mockImplementation( - (path) => + (_path) => ({ isFile: jest.fn().mockReturnValue(true), }) as any, @@ -428,7 +428,7 @@ describe("addCustomInstructions", () => { ] as any) statMock.mockImplementation( - (path) => + (_path) => ({ isFile: jest.fn().mockReturnValue(true), }) as any, diff --git a/src/core/prompts/sections/modes.ts b/src/core/prompts/sections/modes.ts index 50c805dd5dd..0fa5e065760 100644 --- a/src/core/prompts/sections/modes.ts +++ b/src/core/prompts/sections/modes.ts @@ -1,8 +1,8 @@ import * as path from "path" import * as vscode from "vscode" import { promises as fs } from "fs" + import { ModeConfig, getAllModesWithPrompts } from "../../../shared/modes" -import { GlobalFileNames } from "../../../shared/globalFileNames" export async function getModesSection(context: vscode.ExtensionContext): Promise { const settingsDir = path.join(context.globalStorageUri.fsPath, "settings") diff --git a/src/core/prompts/sections/rules.ts b/src/core/prompts/sections/rules.ts index f7a68558894..caafcb48d3f 100644 --- a/src/core/prompts/sections/rules.ts +++ b/src/core/prompts/sections/rules.ts @@ -1,6 +1,6 @@ import { DiffStrategy } from "../../../shared/tools" -function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Record): string { +function getEditingInstructions(diffStrategy?: DiffStrategy): string { const instructions: string[] = [] const availableTools: string[] = [] @@ -44,12 +44,7 @@ function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Recor return instructions.join("\n") } -export function getRulesSection( - cwd: string, - supportsComputerUse: boolean, - diffStrategy?: DiffStrategy, - experiments?: Record | undefined, -): string { +export function getRulesSection(cwd: string, supportsComputerUse: boolean, diffStrategy?: DiffStrategy): string { return `==== RULES @@ -61,7 +56,7 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '${cwd.toPosix()}', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '${cwd.toPosix()}'). For example, if you needed to run \`npm install\` in a project outside of '${cwd.toPosix()}', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using ${diffStrategy ? "apply_diff or write_to_file" : "write_to_file"} to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -${getEditingInstructions(diffStrategy, experiments)} +${getEditingInstructions(diffStrategy)} - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. - Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write. * For example, in architect mode trying to edit app.js would be rejected because architect mode can only edit files matching "\\.md$" diff --git a/src/core/prompts/sections/system-info.ts b/src/core/prompts/sections/system-info.ts index b2cdc99e79c..8adc90a160e 100644 --- a/src/core/prompts/sections/system-info.ts +++ b/src/core/prompts/sections/system-info.ts @@ -1,15 +1,9 @@ -import defaultShell from "default-shell" import os from "os" import osName from "os-name" -import { Mode, ModeConfig, getModeBySlug, defaultModeSlug, isToolAllowedForMode } from "../../../shared/modes" -import { getShell } from "../../../utils/shell" - -export function getSystemInfoSection(cwd: string, currentMode: Mode, customModes?: ModeConfig[]): string { - const findModeBySlug = (slug: string, modes?: ModeConfig[]) => modes?.find((m) => m.slug === slug) - const currentModeName = findModeBySlug(currentMode, customModes)?.name || currentMode - const codeModeName = findModeBySlug(defaultModeSlug, customModes)?.name || "Code" +import { getShell } from "../../../utils/shell" +export function getSystemInfoSection(cwd: string): string { let details = `==== SYSTEM INFORMATION diff --git a/src/core/prompts/system.ts b/src/core/prompts/system.ts index b7bbc06e096..f56a9476637 100644 --- a/src/core/prompts/system.ts +++ b/src/core/prompts/system.ts @@ -3,7 +3,6 @@ import { modes, CustomModePrompts, PromptComponent, - getRoleDefinition, defaultModeSlug, ModeConfig, getModeBySlug, @@ -87,9 +86,9 @@ ${getCapabilitiesSection(cwd, supportsComputerUse, mcpHub, effectiveDiffStrategy ${modesSection} -${getRulesSection(cwd, supportsComputerUse, effectiveDiffStrategy, experiments)} +${getRulesSection(cwd, supportsComputerUse, effectiveDiffStrategy)} -${getSystemInfoSection(cwd, mode, customModeConfigs)} +${getSystemInfoSection(cwd)} ${getObjectiveSection()} diff --git a/src/core/prompts/tools/new-task.ts b/src/core/prompts/tools/new-task.ts index 3de2e6a5373..1bf8848aef4 100644 --- a/src/core/prompts/tools/new-task.ts +++ b/src/core/prompts/tools/new-task.ts @@ -1,6 +1,6 @@ import { ToolArgs } from "./types" -export function getNewTaskDescription(args: ToolArgs): string { +export function getNewTaskDescription(_args: ToolArgs): string { return `## new_task Description: Create a new task with a specified starting mode and initial message. This tool instructs the system to create a new Cline instance in the given mode with the provided message. diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index 967b881d31a..590040f2bab 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -96,8 +96,6 @@ export async function applyDiffTool( error: "No diff strategy available", } - let partResults = "" - if (!diffResult.success) { cline.consecutiveMistakeCount++ const currentCount = (cline.consecutiveMistakeCountForApplyDiff.get(relPath) || 0) + 1 @@ -116,8 +114,6 @@ export async function applyDiffTool( formattedError = `\n${ failPart.error }${errorDetails ? `\n\nDetails:\n${errorDetails}` : ""}\n` - - partResults += formattedError } } else { const errorDetails = diffResult.details ? JSON.stringify(diffResult.details, null, 2) : "" diff --git a/src/core/tools/useMcpToolTool.ts b/src/core/tools/useMcpToolTool.ts index 9a5463355c2..882f214a6f9 100644 --- a/src/core/tools/useMcpToolTool.ts +++ b/src/core/tools/useMcpToolTool.ts @@ -90,7 +90,7 @@ export async function useMcpToolTool( return item.text } if (item.type === "resource") { - const { blob, ...rest } = item.resource + const { blob: _, ...rest } = item.resource return JSON.stringify(rest, null, 2) } return "" diff --git a/src/core/webview/__tests__/ClineProvider.test.ts b/src/core/webview/__tests__/ClineProvider.test.ts index 4c5a28fa4d4..5bdfd0e23e3 100644 --- a/src/core/webview/__tests__/ClineProvider.test.ts +++ b/src/core/webview/__tests__/ClineProvider.test.ts @@ -82,7 +82,7 @@ const mockAddCustomInstructions = jest.fn().mockResolvedValue("Combined instruct // Mock delay module jest.mock("delay", () => { - const delayFn = (ms: number) => Promise.resolve() + const delayFn = (_ms: number) => Promise.resolve() delayFn.createDelay = () => delayFn delayFn.reject = () => Promise.reject(new Error("Delay rejected")) delayFn.range = () => Promise.resolve() @@ -137,7 +137,7 @@ jest.mock("vscode", () => ({ get: jest.fn().mockReturnValue([]), update: jest.fn(), }), - onDidChangeConfiguration: jest.fn().mockImplementation((callback) => ({ + onDidChangeConfiguration: jest.fn().mockImplementation(() => ({ dispose: jest.fn(), })), onDidSaveTextDocument: jest.fn(() => ({ dispose: jest.fn() })), @@ -212,7 +212,7 @@ jest.mock("../../Cline", () => ({ Cline: jest .fn() .mockImplementation( - (provider, apiConfiguration, customInstructions, diffEnabled, fuzzyMatchThreshold, task, taskId) => ({ + (_provider, _apiConfiguration, _customInstructions, _diffEnabled, _fuzzyMatchThreshold, _task, taskId) => ({ api: undefined, abortTask: jest.fn(), handleWebviewAskResponse: jest.fn(), @@ -231,7 +231,7 @@ jest.mock("../../Cline", () => ({ // Mock extract-text jest.mock("../../../integrations/misc/extract-text", () => ({ - extractTextFromFile: jest.fn().mockImplementation(async (filePath: string) => { + extractTextFromFile: jest.fn().mockImplementation(async (_filePath: string) => { const content = "const x = 1;\nconst y = 2;\nconst z = 3;" const lines = content.split("\n") return lines.map((line, index) => `${index + 1} | ${line}`).join("\n") @@ -322,9 +322,7 @@ describe("ClineProvider", () => { callback() return { dispose: jest.fn() } }), - onDidChangeVisibility: jest.fn().mockImplementation((callback) => { - return { dispose: jest.fn() } - }), + onDidChangeVisibility: jest.fn().mockImplementation(() => ({ dispose: jest.fn() })), } as unknown as vscode.WebviewView provider = new ClineProvider(mockContext, mockOutputChannel, "sidebar", new ContextProxy(mockContext)) @@ -1055,7 +1053,7 @@ describe("ClineProvider", () => { // Reset and setup mock mockAddCustomInstructions.mockClear() mockAddCustomInstructions.mockImplementation( - (modeInstructions: string, globalInstructions: string, cwd: string) => { + (modeInstructions: string, globalInstructions: string, _cwd: string) => { return Promise.resolve(modeInstructions || globalInstructions || "") }, ) @@ -2028,7 +2026,6 @@ describe.skip("ContextProxy integration", () => { let mockContext: vscode.ExtensionContext let mockOutputChannel: vscode.OutputChannel let mockContextProxy: any - let mockGlobalStateUpdate: jest.Mock beforeEach(() => { // Reset mocks @@ -2050,8 +2047,6 @@ describe.skip("ContextProxy integration", () => { mockOutputChannel = { appendLine: jest.fn() } as unknown as vscode.OutputChannel mockContextProxy = new ContextProxy(mockContext) provider = new ClineProvider(mockContext, mockOutputChannel, "sidebar", mockContextProxy) - - mockGlobalStateUpdate = mockContext.globalState.update as jest.Mock }) test("updateGlobalState uses contextProxy", async () => { diff --git a/src/integrations/misc/__tests__/line-counter.test.ts b/src/integrations/misc/__tests__/line-counter.test.ts index 12df3e6e897..35c99993abe 100644 --- a/src/integrations/misc/__tests__/line-counter.test.ts +++ b/src/integrations/misc/__tests__/line-counter.test.ts @@ -64,7 +64,7 @@ describe("countFileLines", () => { } const mockReadStream = { - on: jest.fn().mockImplementation(function (this: any, event, callback) { + on: jest.fn().mockImplementation(function (this: any, _event, _callback) { return this }), } @@ -96,7 +96,7 @@ describe("countFileLines", () => { } const mockReadStream = { - on: jest.fn().mockImplementation(function (this: any, event, callback) { + on: jest.fn().mockImplementation(function (this: any, _event, _callback) { return this }), } @@ -126,7 +126,7 @@ describe("countFileLines", () => { } const mockReadStream = { - on: jest.fn().mockImplementation(function (this: any, event, callback) { + on: jest.fn().mockImplementation(function (this: any, _event, _callback) { return this }), } diff --git a/src/integrations/misc/__tests__/performance/processCarriageReturns.benchmark.ts b/src/integrations/misc/__tests__/performance/processCarriageReturns.benchmark.ts index 942ab02c9b7..2862c85bcd0 100644 --- a/src/integrations/misc/__tests__/performance/processCarriageReturns.benchmark.ts +++ b/src/integrations/misc/__tests__/performance/processCarriageReturns.benchmark.ts @@ -354,25 +354,13 @@ function runBenchmark() { const lineLimit = 500 // Standard line limit for truncation console.log("\n--- Function 1: processCarriageReturns ---") - const processCarriageReturnsResult = runPerformanceTest( - "processCarriageReturns", - processCarriageReturns, - testData, - iterations, - ) + runPerformanceTest("processCarriageReturns", processCarriageReturns, testData, iterations) console.log("\n--- Function 2: applyRunLengthEncoding ---") - const applyRunLengthEncodingResult = runPerformanceTest( - "applyRunLengthEncoding", - applyRunLengthEncoding, - testData, - iterations, - ) + runPerformanceTest("applyRunLengthEncoding", applyRunLengthEncoding, testData, iterations) console.log("\n--- Function 3: truncateOutput ---") - const truncateOutputResult = runPerformanceTest("truncateOutput", truncateOutput, testData, iterations, [ - lineLimit, - ]) + runPerformanceTest("truncateOutput", truncateOutput, testData, iterations, [lineLimit]) // Run baseline test to measure variance between identical runs runBaselineTest(testData, Math.max(5, Math.floor(iterations / 4))) diff --git a/src/integrations/misc/extract-text.ts b/src/integrations/misc/extract-text.ts index 596923d93e4..e257e1c8e34 100644 --- a/src/integrations/misc/extract-text.ts +++ b/src/integrations/misc/extract-text.ts @@ -187,7 +187,6 @@ export function applyRunLengthEncoding(content: string): string { let pos = 0 let repeatCount = 0 let prevLine = null - let firstOccurrence = true while (pos < content.length) { const nextNewlineIdx = content.indexOf("\n", pos) // Find next line feed (\n) index diff --git a/src/integrations/misc/read-lines.ts b/src/integrations/misc/read-lines.ts index 1c5db87acb3..5a5eda9f838 100644 --- a/src/integrations/misc/read-lines.ts +++ b/src/integrations/misc/read-lines.ts @@ -7,7 +7,6 @@ * Now you can read a range of lines from a file */ import { createReadStream } from "fs" -import { createInterface } from "readline" const outOfRangeError = (filepath: string, n: number) => { return new RangeError(`Line with index ${n} does not exist in '${filepath}'. Note that line indexing is zero-based`) diff --git a/src/integrations/terminal/TerminalProcess.ts b/src/integrations/terminal/TerminalProcess.ts index a84db00ef30..286480bc76a 100644 --- a/src/integrations/terminal/TerminalProcess.ts +++ b/src/integrations/terminal/TerminalProcess.ts @@ -412,7 +412,8 @@ export class TerminalProcess extends EventEmitter { } // Wait for shell execution to complete and handle exit details - const exitDetails = await shellExecutionComplete + await shellExecutionComplete + this.isHot = false if (commandOutputStarted) { diff --git a/src/integrations/terminal/__tests__/TerminalProcessExec.bash.test.ts b/src/integrations/terminal/__tests__/TerminalProcessExec.bash.test.ts index 109203c5991..22abc3f0413 100644 --- a/src/integrations/terminal/__tests__/TerminalProcessExec.bash.test.ts +++ b/src/integrations/terminal/__tests__/TerminalProcessExec.bash.test.ts @@ -221,7 +221,6 @@ async function testTerminalCommand( const exitDetails = TerminalProcess.interpretExitCode(exitCode) // Set a timeout to avoid hanging tests - let timeoutId: NodeJS.Timeout const timeoutPromise = new Promise((_, reject) => { timeoutId = setTimeout(() => { reject(new Error("Test timed out after 1000ms")) diff --git a/src/integrations/terminal/__tests__/TerminalProcessExec.cmd.test.ts b/src/integrations/terminal/__tests__/TerminalProcessExec.cmd.test.ts index 80d57da6176..c2a4fe30c1a 100644 --- a/src/integrations/terminal/__tests__/TerminalProcessExec.cmd.test.ts +++ b/src/integrations/terminal/__tests__/TerminalProcessExec.cmd.test.ts @@ -69,7 +69,6 @@ async function testCmdCommand( let startTime: bigint = BigInt(0) let endTime: bigint = BigInt(0) let timeRecorded = false - let timeoutId: NodeJS.Timeout | undefined // Create a mock terminal with shell integration const mockTerminal = { diff --git a/src/integrations/terminal/__tests__/TerminalProcessExec.pwsh.test.ts b/src/integrations/terminal/__tests__/TerminalProcessExec.pwsh.test.ts index 3294d1198ee..e6ca6830676 100644 --- a/src/integrations/terminal/__tests__/TerminalProcessExec.pwsh.test.ts +++ b/src/integrations/terminal/__tests__/TerminalProcessExec.pwsh.test.ts @@ -71,7 +71,6 @@ async function testPowerShellCommand( let startTime: bigint = BigInt(0) let endTime: bigint = BigInt(0) let timeRecorded = false - let timeoutId: NodeJS.Timeout | undefined // Create a mock terminal with shell integration const mockTerminal = { diff --git a/src/integrations/terminal/__tests__/TerminalProcessInterpretExitCode.test.ts b/src/integrations/terminal/__tests__/TerminalProcessInterpretExitCode.test.ts index 8a4cfd58f58..f0e312c6119 100644 --- a/src/integrations/terminal/__tests__/TerminalProcessInterpretExitCode.test.ts +++ b/src/integrations/terminal/__tests__/TerminalProcessInterpretExitCode.test.ts @@ -1,20 +1,5 @@ import { TerminalProcess } from "../TerminalProcess" import { execSync } from "child_process" -import { Terminal } from "../Terminal" -import * as vscode from "vscode" - -// Mock vscode.Terminal for testing -const mockTerminal = { - name: "Test Terminal", - processId: Promise.resolve(123), - creationOptions: {}, - exitStatus: undefined, - state: { isInteractedWith: true }, - dispose: jest.fn(), - hide: jest.fn(), - show: jest.fn(), - sendText: jest.fn(), -} as unknown as vscode.Terminal describe("TerminalProcess.interpretExitCode", () => { it("should handle undefined exit code", () => { diff --git a/src/integrations/workspace/WorkspaceTracker.ts b/src/integrations/workspace/WorkspaceTracker.ts index 4621fdc99ea..6c3b7e2a662 100644 --- a/src/integrations/workspace/WorkspaceTracker.ts +++ b/src/integrations/workspace/WorkspaceTracker.ts @@ -1,10 +1,10 @@ import * as vscode from "vscode" import * as path from "path" + import { listFiles } from "../../services/glob/list-files" import { ClineProvider } from "../../core/webview/ClineProvider" import { toRelativePath } from "../../utils/path" import { getWorkspacePath } from "../../utils/path" -import { logger } from "../../utils/logging" const MAX_INITIAL_FILES = 1_000 diff --git a/src/services/browser/BrowserSession.ts b/src/services/browser/BrowserSession.ts index 241865a5488..699b8c7315b 100644 --- a/src/services/browser/BrowserSession.ts +++ b/src/services/browser/BrowserSession.ts @@ -6,7 +6,6 @@ import { Browser, Page, ScreenshotOptions, TimeoutError, launch, connect } from import PCR from "puppeteer-chromium-resolver" import pWaitFor from "p-wait-for" import delay from "delay" -import axios from "axios" import { fileExistsAtPath } from "../../utils/fs" import { BrowserActionResult } from "../../shared/ExtensionMessage" import { discoverChromeHostUrl, tryChromeHostUrl } from "./browserDiscovery" diff --git a/src/services/browser/browserDiscovery.ts b/src/services/browser/browserDiscovery.ts index b17e166a9b5..ecfd1c868a9 100644 --- a/src/services/browser/browserDiscovery.ts +++ b/src/services/browser/browserDiscovery.ts @@ -45,8 +45,7 @@ export async function isPortOpen(host: string, port: number, timeout = 1000): Pr export async function tryChromeHostUrl(chromeHostUrl: string): Promise { try { console.log(`Trying to connect to Chrome at: ${chromeHostUrl}/json/version`) - const response = await axios.get(`${chromeHostUrl}/json/version`, { timeout: 1000 }) - const data = response.data + await axios.get(`${chromeHostUrl}/json/version`, { timeout: 1000 }) return true } catch (error) { return false diff --git a/src/services/checkpoints/types.ts b/src/services/checkpoints/types.ts index 81611e81ec1..0b49c7266d3 100644 --- a/src/services/checkpoints/types.ts +++ b/src/services/checkpoints/types.ts @@ -1,4 +1,4 @@ -import { CommitResult, SimpleGit } from "simple-git" +import { CommitResult } from "simple-git" export type CheckpointResult = Partial & Pick diff --git a/src/services/glob/__mocks__/list-files.ts b/src/services/glob/__mocks__/list-files.ts index 68bc60e730d..07741e4c9a0 100644 --- a/src/services/glob/__mocks__/list-files.ts +++ b/src/services/glob/__mocks__/list-files.ts @@ -21,18 +21,6 @@ const mockResolve = (dirPath: string): string => { return dirPath.startsWith("/") ? dirPath : `/mock/path/${dirPath}` } -/** - * Mock function to check if paths are equal without importing path module - * Provides simple equality comparison for testing - * - * @param path1 - First path to compare - * @param path2 - Second path to compare - * @returns Whether paths are equal - */ -const mockArePathsEqual = (path1: string, path2: string): boolean => { - return path1 === path2 -} - /** * Mock implementation of listFiles function * Returns different results based on input path for testing different scenarios @@ -42,7 +30,7 @@ const mockArePathsEqual = (path1: string, path2: string): boolean => { * @param limit - Maximum number of files to return * @returns Promise resolving to [file paths, limit reached flag] */ -export const listFiles = jest.fn((dirPath: string, recursive: boolean, limit: number) => { +export const listFiles = jest.fn((dirPath: string, _recursive: boolean, _limit: number) => { // Special case: Root or home directories // Prevents tests from trying to list all files in these directories if (dirPath === "/" || dirPath === "/root" || dirPath === "/home/user") { diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 59349ffdbcc..46f59858f9b 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -1,5 +1,5 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js" -import { StdioClientTransport, StdioServerParameters } from "@modelcontextprotocol/sdk/client/stdio.js" +import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js" import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js" import ReconnectingEventSource from "reconnecting-eventsource" import { @@ -205,11 +205,7 @@ export class McpHub { * @param error The error object */ private showErrorMessage(message: string, error: unknown): void { - const errorMessage = error instanceof Error ? error.message : `${error}` console.error(`${message}:`, error) - // if (vscode.window && typeof vscode.window.showErrorMessage === 'function') { - // vscode.window.showErrorMessage(`${message}: ${errorMessage}`) - // } } public setupWorkspaceFoldersWatcher(): void { diff --git a/src/services/mcp/__tests__/McpHub.test.ts b/src/services/mcp/__tests__/McpHub.test.ts index 5df70d0b592..ffd98ff6bda 100644 --- a/src/services/mcp/__tests__/McpHub.test.ts +++ b/src/services/mcp/__tests__/McpHub.test.ts @@ -37,7 +37,6 @@ describe("McpHub", () => { // Store original console methods const originalConsoleError = console.error - const mockSettingsPath = "/mock/settings/path/mcp_settings.json" beforeEach(() => { jest.clearAllMocks() diff --git a/src/services/ripgrep/index.ts b/src/services/ripgrep/index.ts index 89e1da62f80..01e2c26fd16 100644 --- a/src/services/ripgrep/index.ts +++ b/src/services/ripgrep/index.ts @@ -1,8 +1,9 @@ -import * as vscode from "vscode" import * as childProcess from "child_process" import * as path from "path" -import * as fs from "fs" import * as readline from "readline" + +import * as vscode from "vscode" + import { RooIgnoreController } from "../../core/ignore/RooIgnoreController" import { fileExistsAtPath } from "../../utils/fs" /* @@ -160,7 +161,6 @@ export async function regexSearchFiles( } const results: SearchFileResult[] = [] - let currentResult: Partial | null = null let currentFile: SearchFileResult | null = null output.split("\n").forEach((line) => { diff --git a/src/services/tree-sitter/__tests__/helpers.ts b/src/services/tree-sitter/__tests__/helpers.ts index 2ba005e390c..522e6c1cc31 100644 --- a/src/services/tree-sitter/__tests__/helpers.ts +++ b/src/services/tree-sitter/__tests__/helpers.ts @@ -28,8 +28,6 @@ export async function initializeTreeSitter() { } const TreeSitter = await initializeWorkingParser() - const wasmPath = path.join(process.cwd(), "dist/tree-sitter-tsx.wasm") - const tsxLang = await TreeSitter.Language.load(wasmPath) initializedTreeSitter = TreeSitter return TreeSitter @@ -68,7 +66,6 @@ export async function testParseSourceCodeDefinitions( } = {}, ): Promise { // Set default options - const language = options.language || "tsx" const wasmFile = options.wasmFile || "tree-sitter-tsx.wasm" const queryString = options.queryString || tsxQuery const extKey = options.extKey || "tsx" diff --git a/src/services/tree-sitter/__tests__/index.test.ts b/src/services/tree-sitter/__tests__/index.test.ts index 951a86f19c3..d25b9abef5e 100644 --- a/src/services/tree-sitter/__tests__/index.test.ts +++ b/src/services/tree-sitter/__tests__/index.test.ts @@ -1,9 +1,9 @@ +import * as fs from "fs/promises" + import { parseSourceCodeForDefinitionsTopLevel } from "../index" import { listFiles } from "../../glob/list-files" import { loadRequiredLanguageParsers } from "../languageParser" import { fileExistsAtPath } from "../../../utils/fs" -import * as fs from "fs/promises" -import * as path from "path" // Mock dependencies jest.mock("../../glob/list-files") diff --git a/src/services/tree-sitter/__tests__/markdownIntegration.test.ts b/src/services/tree-sitter/__tests__/markdownIntegration.test.ts index 1d8b669a91c..dc88e37dd4b 100644 --- a/src/services/tree-sitter/__tests__/markdownIntegration.test.ts +++ b/src/services/tree-sitter/__tests__/markdownIntegration.test.ts @@ -1,6 +1,7 @@ -import { describe, expect, it, jest, beforeEach } from "@jest/globals" import * as fs from "fs/promises" -import * as path from "path" + +import { describe, expect, it, jest, beforeEach } from "@jest/globals" + import { parseSourceCodeDefinitionsForFile } from "../index" // Mock fs.readFile diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.cpp.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.cpp.test.ts index c9d94bd0528..43c03a1ea53 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.cpp.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.cpp.test.ts @@ -1,12 +1,7 @@ import { describe, expect, it, jest, beforeEach } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." -import * as fs from "fs/promises" -import * as path from "path" -import Parser from "web-tree-sitter" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" + import { cppQuery } from "../queries" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" +import { testParseSourceCodeDefinitions } from "./helpers" // Sample C++ content for tests covering all supported structures: // - struct declarations @@ -516,7 +511,6 @@ const cppOptions = { // Mock file system operations jest.mock("fs/promises") -const mockedFs = jest.mocked(fs) // Mock loadRequiredLanguageParsers jest.mock("../languageParser", () => ({ @@ -654,12 +648,10 @@ describe("parseSourceCodeDefinitionsForFile with C++", () => { }) it("should parse C++ using declarations and aliases", async () => { - const result = await testParseSourceCodeDefinitions("/test/file.cpp", sampleCppContent, cppOptions) - const resultLines = result?.split("\n") || [] - + // const result = await testParseSourceCodeDefinitions("/test/file.cpp", sampleCppContent, cppOptions) + // const resultLines = result?.split("\n") || [] // Test using declarations - not supported by current parser // expect(resultLines.some((line) => line.includes("using std::string"))).toBe(true) - // Test using directives - not supported by current parser // expect(resultLines.some((line) => line.includes("using namespace std"))).toBe(true) // Test alias declarations - not supported by current parser @@ -683,12 +675,10 @@ describe("parseSourceCodeDefinitionsForFile with C++", () => { }) it("should parse C++ attributes and macros", async () => { - const result = await testParseSourceCodeDefinitions("/test/file.cpp", sampleCppContent, cppOptions) - const resultLines = result?.split("\n") || [] - + // const result = await testParseSourceCodeDefinitions("/test/file.cpp", sampleCppContent, cppOptions) + // const resultLines = result?.split("\n") || [] // Test attributes - not supported by current parser // expect(resultLines.some((line) => line.includes("[[nodiscard]]") || line.includes("attribute_declaration"))).toBe(true) - // Test macro definitions - not supported by current parser // expect(resultLines.some((line) => line.includes("#define SQUARE"))).toBe(true) }) @@ -721,12 +711,10 @@ describe("parseSourceCodeDefinitionsForFile with C++", () => { }) it("should parse C++ inline functions and variables", async () => { - const result = await testParseSourceCodeDefinitions("/test/file.cpp", sampleCppContent, cppOptions) - const resultLines = result?.split("\n") || [] - + // const result = await testParseSourceCodeDefinitions("/test/file.cpp", sampleCppContent, cppOptions) + // const resultLines = result?.split("\n") || [] // Test inline functions - not supported by current parser // expect(resultLines.some((line) => line.includes("inline double square"))).toBe(true) - // Test inline variables - not supported by current parser // expect(resultLines.some((line) => line.includes("inline constexpr double PI"))).toBe(true) }) diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.go.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.go.test.ts index ae851368c6c..137809626d8 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.go.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.go.test.ts @@ -1,12 +1,7 @@ import { describe, expect, it, jest, beforeEach } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." -import * as fs from "fs/promises" -import * as path from "path" -import Parser from "web-tree-sitter" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" + import { goQuery } from "../queries" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" +import { testParseSourceCodeDefinitions } from "./helpers" // Sample Go content for tests covering all supported structures: // - function declarations (with associated comments) @@ -260,7 +255,6 @@ const goOptions = { // Mock file system operations jest.mock("fs/promises") -const mockedFs = jest.mocked(fs) // Mock loadRequiredLanguageParsers jest.mock("../languageParser", () => ({ @@ -279,7 +273,6 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { it("should parse Go struct definitions", async () => { const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] // Check for struct definitions - we only check for the ones that are actually captured expect(result).toContain("type Point struct") @@ -289,7 +282,6 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { it("should parse Go method declarations", async () => { const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] // Check for method declarations - we only check for the ones that are actually captured expect(result).toContain("func (p *Point) Move") @@ -298,7 +290,6 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { it("should parse Go function declarations", async () => { const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] // Check for function declarations - we only check for the ones that are actually captured expect(result).toContain("func CalculateDistance") @@ -308,7 +299,6 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { it("should parse Go interface definitions", async () => { const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] // Check for interface definitions - we only check for the ones that are actually captured expect(result).toContain("type Shape interface") @@ -327,8 +317,7 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { }) it("should parse Go type aliases", async () => { - const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] + await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) // Note: Type aliases might not be captured due to Tree-Sitter parser limitations // This test is kept for completeness @@ -336,9 +325,7 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { }) it("should parse Go embedded structs and interfaces", async () => { - const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] - + await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) // Note: Embedded structs and interfaces might not be captured due to Tree-Sitter parser limitations // This test is kept for completeness expect(true).toBe(true) @@ -346,7 +333,6 @@ describe("parseSourceCodeDefinitionsForFile with Go", () => { it("should parse Go init functions", async () => { const result = await testParseSourceCodeDefinitions("/test/file.go", sampleGoContent, goOptions) - const resultLines = result?.split("\n") || [] // Check for init functions expect(result).toContain("func init") diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.java.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.java.test.ts index ebaeef65665..3f27300275e 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.java.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.java.test.ts @@ -1,12 +1,7 @@ import { describe, expect, it, jest, beforeEach } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." -import * as fs from "fs/promises" -import * as path from "path" -import Parser from "web-tree-sitter" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" + import { javaQuery } from "../queries" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" +import { testParseSourceCodeDefinitions } from "./helpers" // Sample Java content for tests covering all supported structures: // - class declarations (including inner and anonymous classes) @@ -309,7 +304,6 @@ const javaOptions = { // Mock file system operations jest.mock("fs/promises") -const mockedFs = jest.mocked(fs) // Mock loadRequiredLanguageParsers jest.mock("../languageParser", () => ({ diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.json.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.json.test.ts index a23f00c64c3..e9b902c0141 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.json.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.json.test.ts @@ -1,11 +1,10 @@ -import { describe, expect, it, jest, beforeEach } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." import * as fs from "fs/promises" import * as path from "path" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" + +import { describe, expect, it, jest, beforeEach } from "@jest/globals" + import { javascriptQuery } from "../queries" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" +import { initializeTreeSitter, testParseSourceCodeDefinitions, debugLog } from "./helpers" // Sample JSON content for tests const sampleJsonContent = `{ @@ -68,9 +67,6 @@ describe("jsonParserDebug", () => { parser.setLanguage(jsLang) const tree = parser.parse(sampleJsonContent) - // Extract definitions using JavaScript query - const query = jsLang.query(javascriptQuery) - expect(tree).toBeDefined() }) diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.python.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.python.test.ts index 4c1ea34b32f..cf3fb59cbba 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.python.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.python.test.ts @@ -1,12 +1,7 @@ import { describe, expect, it, jest, beforeEach } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." -import * as fs from "fs/promises" -import * as path from "path" -import Parser from "web-tree-sitter" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" + import { pythonQuery } from "../queries" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" +import { testParseSourceCodeDefinitions } from "./helpers" // Sample Python content for tests covering all supported structures: // - class definitions @@ -355,7 +350,6 @@ const pythonOptions = { // Mock file system operations jest.mock("fs/promises") -const mockedFs = jest.mocked(fs) // Mock loadRequiredLanguageParsers jest.mock("../languageParser", () => ({ @@ -374,7 +368,6 @@ describe("parseSourceCodeDefinitionsForFile with Python", () => { it("should parse Python class definitions", async () => { const result = await testParseSourceCodeDefinitions("/test/file.py", samplePythonContent, pythonOptions) - const resultLines = result?.split("\n") || [] // Check for class definitions expect(result).toContain("class Point") @@ -386,7 +379,6 @@ describe("parseSourceCodeDefinitionsForFile with Python", () => { it("should parse Python function definitions", async () => { const result = await testParseSourceCodeDefinitions("/test/file.py", samplePythonContent, pythonOptions) - const resultLines = result?.split("\n") || [] // Check for function definitions expect(result).toContain("def calculate_average") diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.rust.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.rust.test.ts index fe5bc1a4a13..4b992406c6a 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.rust.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.rust.test.ts @@ -1,12 +1,7 @@ import { describe, expect, it, jest, beforeEach } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." -import * as fs from "fs/promises" -import * as path from "path" -import Parser from "web-tree-sitter" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" + import { rustQuery } from "../queries" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" +import { testParseSourceCodeDefinitions } from "./helpers" // Sample Rust content for tests covering all supported structures: // - struct definitions @@ -318,7 +313,6 @@ const rustOptions = { // Mock file system operations jest.mock("fs/promises") -const mockedFs = jest.mocked(fs) // Mock loadRequiredLanguageParsers jest.mock("../languageParser", () => ({ diff --git a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.tsx.test.ts b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.tsx.test.ts index f03382b024c..eef530c2db2 100644 --- a/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.tsx.test.ts +++ b/src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.tsx.test.ts @@ -1,11 +1,11 @@ -import { describe, expect, it, jest, beforeEach, beforeAll } from "@jest/globals" -import { parseSourceCodeDefinitionsForFile } from ".." +// npx jest src/services/tree-sitter/__tests__/parseSourceCodeDefinitions.tsx.test.ts + import * as fs from "fs/promises" import * as path from "path" -import { fileExistsAtPath } from "../../../utils/fs" -import { loadRequiredLanguageParsers } from "../languageParser" -import tsxQuery from "../queries/tsx" -import { initializeTreeSitter, testParseSourceCodeDefinitions, inspectTreeStructure, debugLog } from "./helpers" + +import { describe, expect, it, jest, beforeEach } from "@jest/globals" + +import { initializeTreeSitter, testParseSourceCodeDefinitions, debugLog } from "./helpers" // Sample component content with enhanced TypeScript language constructs const sampleTsxContent = ` @@ -338,9 +338,6 @@ describe("treeParserDebug", () => { const tree = parser.parse(sampleCode) // console.log("Parsed tree:", tree.rootNode.toString()) - // Extract definitions using TSX query - const query = tsxLang.query(tsxQuery) - expect(tree).toBeDefined() }) @@ -571,7 +568,6 @@ it("should parse conditional types", async function () { // Save the initial line count to compare later const initialLineCount = initialResult ? initialResult.split("\n").length : 0 - const initialCaptures = initialResult ? initialResult : "" // Now check if the new query pattern improves the output const updatedResult = await testParseSourceCodeDefinitions("/test/conditional-type.tsx", conditionalTypeContent) diff --git a/src/services/tree-sitter/index.ts b/src/services/tree-sitter/index.ts index c9573e40dd2..529add14f84 100644 --- a/src/services/tree-sitter/index.ts +++ b/src/services/tree-sitter/index.ts @@ -3,7 +3,7 @@ import * as path from "path" import { listFiles } from "../glob/list-files" import { LanguageParser, loadRequiredLanguageParsers } from "./languageParser" import { fileExistsAtPath } from "../../utils/fs" -import { parseMarkdown, formatMarkdownCaptures } from "./markdownParser" +import { parseMarkdown } from "./markdownParser" import { RooIgnoreController } from "../../core/ignore/RooIgnoreController" const extensions = [ @@ -109,7 +109,7 @@ export async function parseSourceCodeForDefinitionsTopLevel( let result = "" // Separate files to parse and remaining files - const { filesToParse, remainingFiles } = separateFiles(allFiles) + const { filesToParse } = separateFiles(allFiles) // Filter filepaths for access if controller is provided const allowedFilesToParse = rooIgnoreController ? rooIgnoreController.filterPaths(filesToParse) : filesToParse @@ -227,9 +227,6 @@ function processCaptures(captures: any[], lines: string[], minComponentLines: nu // Sort captures by their start position captures.sort((a, b) => a.node.startPosition.row - b.node.startPosition.row) - // Keep track of the last line we've processed - let lastLine = -1 - // Track already processed lines to avoid duplicates const processedLines = new Set() @@ -300,13 +297,12 @@ function processCaptures(captures: any[], lines: string[], minComponentLines: nu } } } - - lastLine = endLine }) if (formattedOutput.length > 0) { return formattedOutput } + return null } diff --git a/src/shared/__tests__/vsCodeSelectorUtils.test.ts b/src/shared/__tests__/vsCodeSelectorUtils.test.ts index 6e6c188bc08..3c2e6108474 100644 --- a/src/shared/__tests__/vsCodeSelectorUtils.test.ts +++ b/src/shared/__tests__/vsCodeSelectorUtils.test.ts @@ -1,4 +1,4 @@ -import { stringifyVsCodeLmModelSelector, SELECTOR_SEPARATOR } from "../vsCodeSelectorUtils" +import { stringifyVsCodeLmModelSelector } from "../vsCodeSelectorUtils" import { LanguageModelChatSelector } from "vscode" describe("vsCodeSelectorUtils", () => { diff --git a/src/utils/__tests__/git.test.ts b/src/utils/__tests__/git.test.ts index 629849c2360..f2814339fc8 100644 --- a/src/utils/__tests__/git.test.ts +++ b/src/utils/__tests__/git.test.ts @@ -1,7 +1,8 @@ import { jest } from "@jest/globals" -import { searchCommits, getCommitInfo, getWorkingState, GitCommit } from "../git" import { ExecException } from "child_process" +import { searchCommits, getCommitInfo, getWorkingState } from "../git" + type ExecFunction = ( command: string, options: { cwd?: string }, diff --git a/src/utils/logging/CompactLogger.ts b/src/utils/logging/CompactLogger.ts index 4fc27ed58ab..949c24de0b3 100644 --- a/src/utils/logging/CompactLogger.ts +++ b/src/utils/logging/CompactLogger.ts @@ -142,7 +142,7 @@ export class CompactLogger implements ILogger { l: level, m: message, c: meta?.ctx, - d: meta ? (({ ctx, ...rest }) => (Object.keys(rest).length > 0 ? rest : undefined))(meta) : undefined, + d: meta ? (({ ctx: _, ...rest }) => (Object.keys(rest).length > 0 ? rest : undefined))(meta) : undefined, } this.transport.write(entry) diff --git a/webview-ui/package.json b/webview-ui/package.json index 8267a7e918c..91ba3d76dce 100644 --- a/webview-ui/package.json +++ b/webview-ui/package.json @@ -4,8 +4,7 @@ "private": true, "type": "module", "scripts": { - "lint": "eslint src/**/*.ts src/**/*.tsx", - "lint-fix": "eslint src/**/*.ts src/**/*.tsx --fix", + "lint": "eslint src --ext .ts,.tsx", "check-types": "tsc", "test": "jest -w=40%", "dev": "vite", diff --git a/webview-ui/src/components/chat/Announcement.tsx b/webview-ui/src/components/chat/Announcement.tsx index 26ccd6e55b1..8654b766263 100644 --- a/webview-ui/src/components/chat/Announcement.tsx +++ b/webview-ui/src/components/chat/Announcement.tsx @@ -10,7 +10,7 @@ interface AnnouncementProps { /* You must update the latestAnnouncementId in ClineProvider for new announcements to show to users. This new id will be compared with whats in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves. */ -const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => { +const Announcement = ({ hideAnnouncement }: AnnouncementProps) => { const { t } = useAppTranslation() const discordLink = ( diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index 9cfeddd5ea4..2c60d5f1aec 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -94,11 +94,12 @@ const ChatTextArea = forwardRef( // Close dropdown when clicking outside. useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { + const handleClickOutside = () => { if (showDropdown) { setShowDropdown(false) } } + document.addEventListener("mousedown", handleClickOutside) return () => document.removeEventListener("mousedown", handleClickOutside) }, [showDropdown]) diff --git a/webview-ui/src/components/chat/ContextMenu.tsx b/webview-ui/src/components/chat/ContextMenu.tsx index f6fe6d9e834..123a8110fc2 100644 --- a/webview-ui/src/components/chat/ContextMenu.tsx +++ b/webview-ui/src/components/chat/ContextMenu.tsx @@ -33,7 +33,6 @@ const ContextMenu: React.FC = ({ selectedType, queryItems, modes, - loading = false, dynamicSearchResults = [], }) => { const [materialIconsBaseUri, setMaterialIconsBaseUri] = useState("") diff --git a/webview-ui/src/components/chat/__tests__/ChatTextArea.test.tsx b/webview-ui/src/components/chat/__tests__/ChatTextArea.test.tsx index 2262f1494da..0f8ad2cbc64 100644 --- a/webview-ui/src/components/chat/__tests__/ChatTextArea.test.tsx +++ b/webview-ui/src/components/chat/__tests__/ChatTextArea.test.tsx @@ -360,7 +360,7 @@ describe("ChatTextArea", () => { const outsidePath = "/Users/other/project/file.js" // Mock the convertToMentionPath function to return the original path for paths outside cwd - mockConvertToMentionPath.mockImplementationOnce((path, cwd) => { + mockConvertToMentionPath.mockImplementationOnce((path, _cwd) => { return path // Return original path for this test }) diff --git a/webview-ui/src/components/common/CodeBlock.tsx b/webview-ui/src/components/common/CodeBlock.tsx index 04da931bd14..d5d41940a3b 100644 --- a/webview-ui/src/components/common/CodeBlock.tsx +++ b/webview-ui/src/components/common/CodeBlock.tsx @@ -100,7 +100,7 @@ const StyledPre = styled.pre<{ theme: any }>` ${(props) => Object.keys(props.theme) - .map((key, index) => { + .map((key) => { return ` & ${key} { color: ${props.theme[key]}; @@ -135,7 +135,7 @@ const CodeBlock = memo(({ source, forceWrap = false }: CodeBlockProps) => { ], rehypeReactOptions: { components: { - pre: ({ node, ...preProps }: any) => , + pre: ({ node: _, ...preProps }: any) => , }, }, }) diff --git a/webview-ui/src/components/common/MarkdownBlock.tsx b/webview-ui/src/components/common/MarkdownBlock.tsx index e8ff7067138..22aa345dfd6 100644 --- a/webview-ui/src/components/common/MarkdownBlock.tsx +++ b/webview-ui/src/components/common/MarkdownBlock.tsx @@ -160,7 +160,7 @@ const StyledPre = styled.pre<{ theme: any }>` ${(props) => Object.keys(props.theme) - .map((key, index) => { + .map((key) => { return ` & ${key} { color: ${props.theme[key]}; @@ -195,7 +195,7 @@ const MarkdownBlock = memo(({ markdown }: MarkdownBlockProps) => { ], rehypeReactOptions: { components: { - pre: ({ node, children, ...preProps }: any) => { + pre: ({ node: _, children, ...preProps }: any) => { if (Array.isArray(children) && children.length === 1 && React.isValidElement(children[0])) { const child = children[0] as React.ReactElement<{ className?: string }> if (child.props?.className?.includes("language-mermaid")) { diff --git a/webview-ui/src/components/prompts/PromptsView.tsx b/webview-ui/src/components/prompts/PromptsView.tsx index e53bea24609..61c61490e71 100644 --- a/webview-ui/src/components/prompts/PromptsView.tsx +++ b/webview-ui/src/components/prompts/PromptsView.tsx @@ -316,7 +316,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { // Handle clicks outside the config menu useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { + const handleClickOutside = () => { if (showConfigMenu) { setShowConfigMenu(false) } diff --git a/webview-ui/src/components/settings/AutoApproveSettings.tsx b/webview-ui/src/components/settings/AutoApproveSettings.tsx index 8b71dbdfed9..e75b7ff723a 100644 --- a/webview-ui/src/components/settings/AutoApproveSettings.tsx +++ b/webview-ui/src/components/settings/AutoApproveSettings.tsx @@ -57,7 +57,6 @@ export const AutoApproveSettings = ({ alwaysAllowExecute, allowedCommands, setCachedStateField, - className, ...props }: AutoApproveSettingsProps) => { const { t } = useAppTranslation() diff --git a/webview-ui/src/components/settings/ExperimentalSettings.tsx b/webview-ui/src/components/settings/ExperimentalSettings.tsx index 7b962ccfed5..5e060832cf0 100644 --- a/webview-ui/src/components/settings/ExperimentalSettings.tsx +++ b/webview-ui/src/components/settings/ExperimentalSettings.tsx @@ -18,7 +18,6 @@ type ExperimentalSettingsProps = HTMLAttributes & { } export const ExperimentalSettings = ({ - setCachedStateField, experiments, setExperimentEnabled, className, diff --git a/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx b/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx index d6a82bc0e4d..37cbdabcda1 100644 --- a/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx +++ b/webview-ui/src/components/settings/__tests__/ApiConfigManager.test.tsx @@ -1,6 +1,5 @@ // npx jest src/components/settings/__tests__/ApiConfigManager.test.tsx -import React from "react" import { render, screen, fireEvent, within } from "@testing-library/react" import ApiConfigManager from "../ApiConfigManager" @@ -21,14 +20,14 @@ jest.mock("@vscode/webview-ui-toolkit/react", () => ({ jest.mock("@/components/ui", () => ({ ...jest.requireActual("@/components/ui"), - Dialog: ({ children, open, onOpenChange }: any) => ( + Dialog: ({ children, open }: any) => (
{children}
), DialogContent: ({ children }: any) =>
{children}
, DialogTitle: ({ children }: any) =>
{children}
, - Button: ({ children, onClick, disabled, variant, "data-testid": dataTestId }: any) => ( + Button: ({ children, onClick, disabled, "data-testid": dataTestId }: any) => ( @@ -43,16 +42,16 @@ jest.mock("@/components/ui", () => ({ /> ), // New components for searchable dropdown - Popover: ({ children, open, onOpenChange }: any) => ( + Popover: ({ children, open }: any) => (
{children} {open &&
}
), - PopoverTrigger: ({ children, asChild }: any) =>
{children}
, - PopoverContent: ({ children, className }: any) =>
{children}
, + PopoverTrigger: ({ children }: any) =>
{children}
, + PopoverContent: ({ children }: any) =>
{children}
, Command: ({ children }: any) =>
{children}
, - CommandInput: ({ value, onValueChange, placeholder, className, "data-testid": dataTestId, ref }: any) => ( + CommandInput: ({ value, onValueChange, placeholder, className, "data-testid": dataTestId }: any) => ( onValueChange(e.target.value)} @@ -70,7 +69,7 @@ jest.mock("@/components/ui", () => ({ ), // Keep old components for backward compatibility - Select: ({ children, value, onValueChange }: any) => ( + Select: ({ value, onValueChange }: any) => (