Skip to content

Commit 1924e10

Browse files
authored
Fix all linter errors (and fix the lint scripts too) (#2958)
1 parent 418791a commit 1924e10

File tree

93 files changed

+181
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+181
-413
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
"install-webview": "cd webview-ui && npm install",
365365
"install-e2e": "cd e2e && npm install",
366366
"lint": "npm-run-all -l -p lint:*",
367-
"lint:extension": "eslint src/**/*.ts",
367+
"lint:extension": "eslint src --ext .ts",
368368
"lint:webview": "cd webview-ui && npm run lint",
369369
"lint:e2e": "cd e2e && npm run lint",
370370
"check-types": "npm-run-all -l -p check-types:*",

src/__mocks__/fs/promises.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ const baseTestDirs = [
2424
"/test/log/path",
2525
]
2626

27-
// Helper function to format instructions
28-
const formatInstructions = (sections: string[]): string => {
29-
const joinedSections = sections.filter(Boolean).join("\n\n")
30-
return joinedSections
31-
? `
32-
====
33-
34-
USER'S CUSTOM INSTRUCTIONS
35-
36-
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.
37-
38-
${joinedSections}`
39-
: ""
40-
}
41-
42-
// Helper function to format rule content
43-
const formatRuleContent = (ruleFile: string, content: string): string => {
44-
return `Rules:\n# Rules from ${ruleFile}:\n${content}`
45-
}
46-
4727
type RuleFiles = {
4828
".clinerules-code": string
4929
".clinerules-ask": string
@@ -65,7 +45,7 @@ const ensureDirectoryExists = (path: string) => {
6545
}
6646

6747
const mockFs = {
68-
readFile: jest.fn().mockImplementation(async (filePath: string, encoding?: string) => {
48+
readFile: jest.fn().mockImplementation(async (filePath: string, _encoding?: string) => {
6949
// Return stored content if it exists
7050
if (mockFiles.has(filePath)) {
7151
return mockFiles.get(filePath)

src/__mocks__/services/ripgrep/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @param vscodeAppRoot - Optional VSCode app root path (can be undefined)
1414
* @returns Promise resolving to a mock path to the ripgrep binary
1515
*/
16-
export const getBinPath = jest.fn().mockImplementation(async (vscodeAppRoot?: string): Promise<string> => {
16+
export const getBinPath = jest.fn().mockImplementation(async (_vscodeAppRoot?: string): Promise<string> => {
1717
return "/mock/path/to/rg"
1818
})
1919

@@ -30,7 +30,7 @@ export const getBinPath = jest.fn().mockImplementation(async (vscodeAppRoot?: st
3030
export const regexSearchFiles = jest
3131
.fn()
3232
.mockImplementation(
33-
async (cwd?: string, directoryPath?: string, regex?: string, filePattern?: string): Promise<string> => {
33+
async (_cwd?: string, _directoryPath?: string, _regex?: string, _filePattern?: string): Promise<string> => {
3434
return "Mock search results"
3535
},
3636
)
@@ -43,6 +43,6 @@ export const regexSearchFiles = jest
4343
* @param maxLength - Optional maximum length (can be undefined)
4444
* @returns The original line or empty string if undefined
4545
*/
46-
export const truncateLine = jest.fn().mockImplementation((line?: string, maxLength?: number): string => {
46+
export const truncateLine = jest.fn().mockImplementation((line?: string, _maxLength?: number): string => {
4747
return line || ""
4848
})

src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function buildApiHandler(configuration: ApiConfiguration): ApiHandler {
7777
case "requesty":
7878
return new RequestyHandler(options)
7979
case "human-relay":
80-
return new HumanRelayHandler(options)
80+
return new HumanRelayHandler()
8181
case "fake-ai":
8282
return new FakeAIHandler(options)
8383
case "xai":

src/api/providers/__tests__/bedrock-custom-arn.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// npx jest src/api/providers/__tests__/bedrock-custom-arn.test.ts
2+
13
import { AwsBedrockHandler } from "../bedrock"
24
import { ApiHandlerOptions } from "../../../shared/api"
35
import { logger } from "../../../utils/logging"
@@ -52,9 +54,6 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => {
5254
}
5355
})
5456

55-
// Get mock module for testing
56-
const bedrockMock = jest.requireMock("@aws-sdk/client-bedrock-runtime").__mock
57-
5857
describe("Bedrock ARN Handling", () => {
5958
// Helper function to create a handler with specific options
6059
const createHandler = (options: Partial<ApiHandlerOptions> = {}) => {
@@ -236,7 +235,8 @@ describe("Bedrock ARN Handling", () => {
236235
// Create handler with ARN region different from provided region
237236
const arn =
238237
"arn:aws:bedrock:eu-west-1:123456789012:inference-profile/anthropic.claude-3-sonnet-20240229-v1:0"
239-
const handler = createHandler({
238+
239+
createHandler({
240240
awsCustomArn: arn,
241241
awsRegion: "us-east-1", // Different from ARN region
242242
})

src/api/providers/__tests__/bedrock-invokedModelId.test.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// npx jest src/api/providers/__tests__/bedrock-invokedModelId.test.ts
2+
3+
import { ApiHandlerOptions } from "../../../shared/api"
4+
5+
import { AwsBedrockHandler, StreamEvent } from "../bedrock"
6+
17
// Mock AWS SDK credential providers and Bedrock client
28
jest.mock("@aws-sdk/credential-providers", () => ({
39
fromIni: jest.fn().mockReturnValue({
@@ -62,11 +68,6 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => {
6268
}
6369
})
6470

65-
import { AwsBedrockHandler, StreamEvent } from "../bedrock"
66-
import { ApiHandlerOptions } from "../../../shared/api"
67-
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime"
68-
const { fromIni } = require("@aws-sdk/credential-providers")
69-
7071
describe("AwsBedrockHandler with invokedModelId", () => {
7172
let mockSend: jest.Mock
7273

@@ -279,17 +280,6 @@ describe("AwsBedrockHandler with invokedModelId", () => {
279280
}
280281
})
281282

282-
// Mock getModel to return expected values
283-
const getModelSpy = jest.spyOn(handler, "getModel").mockReturnValue({
284-
id: "anthropic.claude-3-5-sonnet-20241022-v2:0",
285-
info: {
286-
maxTokens: 4096,
287-
contextWindow: 128_000,
288-
supportsPromptCache: false,
289-
supportsImages: true,
290-
},
291-
})
292-
293283
// Create a message generator
294284
const messageGenerator = handler.createMessage("system prompt", [{ role: "user", content: "user message" }])
295285

src/api/providers/__tests__/bedrock.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ jest.mock("@aws-sdk/client-bedrock-runtime", () => ({
2222
}))
2323

2424
import { AwsBedrockHandler } from "../bedrock"
25-
import { MessageContent } from "../../../shared/api"
26-
import { BedrockRuntimeClient, ConverseStreamCommand } from "@aws-sdk/client-bedrock-runtime"
25+
2726
import { Anthropic } from "@anthropic-ai/sdk"
28-
const { fromIni } = require("@aws-sdk/credential-providers")
29-
import { logger } from "../../../utils/logging"
3027

3128
describe("AwsBedrockHandler", () => {
3229
let handler: AwsBedrockHandler

src/api/providers/__tests__/gemini.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe("GeminiHandler", () => {
9595
const stream = handler.createMessage(systemPrompt, mockMessages)
9696

9797
await expect(async () => {
98-
for await (const chunk of stream) {
98+
for await (const _chunk of stream) {
9999
// Should throw before yielding any chunks
100100
}
101101
}).rejects.toThrow()

src/api/providers/__tests__/lmstudio.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { Anthropic } from "@anthropic-ai/sdk"
2+
13
import { LmStudioHandler } from "../lmstudio"
24
import { ApiHandlerOptions } from "../../../shared/api"
3-
import OpenAI from "openai"
4-
import { Anthropic } from "@anthropic-ai/sdk"
55

66
// Mock OpenAI client
77
const mockCreate = jest.fn()
@@ -120,7 +120,7 @@ describe("LmStudioHandler", () => {
120120
const stream = handler.createMessage(systemPrompt, messages)
121121

122122
await expect(async () => {
123-
for await (const chunk of stream) {
123+
for await (const _chunk of stream) {
124124
// Should not reach here
125125
}
126126
}).rejects.toThrow("Please check the LM Studio developer logs to debug what went wrong")

src/api/providers/__tests__/mistral.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { MistralHandler } from "../mistral"
2-
import { ApiHandlerOptions, mistralDefaultModelId } from "../../../shared/api"
31
import { Anthropic } from "@anthropic-ai/sdk"
2+
3+
import { MistralHandler } from "../mistral"
4+
import { ApiHandlerOptions } from "../../../shared/api"
45
import { ApiStreamTextChunk } from "../../transform/stream"
56

67
// Mock Mistral client
@@ -9,7 +10,7 @@ jest.mock("@mistralai/mistralai", () => {
910
return {
1011
Mistral: jest.fn().mockImplementation(() => ({
1112
chat: {
12-
stream: mockCreate.mockImplementation(async (options) => {
13+
stream: mockCreate.mockImplementation(async (_options) => {
1314
const stream = {
1415
[Symbol.asyncIterator]: async function* () {
1516
yield {

0 commit comments

Comments
 (0)