Skip to content

Commit 21dd749

Browse files
committed
chore: re-enable the prefer-const ESLint rule
prefer-const was disabled in src/eslint.config.mjs under a "TODO: re-enable" comment. Re-enabled with { destructuring: "all" } so it only flags a destructuring declaration when every binding can be const. Most violations were auto-fixed (let -> const); five declare-then-assign cases were merged by hand into a single const declaration. No behavior change — tsc and the tests for the touched modules pass.
1 parent 166bc3f commit 21dd749

41 files changed

Lines changed: 80 additions & 81 deletions

Some content is hidden

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

src/api/providers/anthropic-vertex.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
6868
messages: Anthropic.Messages.MessageParam[],
6969
metadata?: ApiHandlerCreateMessageMetadata,
7070
): ApiStream {
71-
let { id, info, temperature, maxTokens, reasoning: thinking, betas } = this.getModel()
71+
const { id, info, temperature, maxTokens, reasoning: thinking, betas } = this.getModel()
7272

7373
const { supportsPromptCache } = info
7474

@@ -207,7 +207,7 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
207207

208208
getModel() {
209209
const modelId = this.options.apiModelId
210-
let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId
210+
const id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId
211211
let info: ModelInfo = vertexModels[id]
212212

213213
// Check if 1M context beta should be enabled for supported models
@@ -261,7 +261,7 @@ export class AnthropicVertexHandler extends BaseProvider implements SingleComple
261261

262262
async completePrompt(prompt: string) {
263263
try {
264-
let {
264+
const {
265265
id,
266266
info: { supportsPromptCache },
267267
temperature,

src/api/providers/anthropic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
5454
): ApiStream {
5555
let stream: AnthropicStream<Anthropic.Messages.RawMessageStreamEvent>
5656
const cacheControl: CacheControlEphemeral = { type: "ephemeral" }
57-
let {
57+
const {
5858
id: modelId,
5959
betas = ["fine-grained-tool-streaming-2025-05-14"],
6060
maxTokens,
@@ -348,7 +348,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
348348

349349
getModel() {
350350
const modelId = this.options.apiModelId
351-
let id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId
351+
const id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId
352352
let info: ModelInfo = anthropicModels[id]
353353

354354
// If 1M context beta is enabled for supported models, update the model info
@@ -394,7 +394,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
394394
}
395395

396396
async completePrompt(prompt: string) {
397-
let { id: model, temperature } = this.getModel()
397+
const { id: model, temperature } = this.getModel()
398398

399399
let message
400400
try {

src/api/providers/bedrock.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
205205
constructor(options: ProviderSettings) {
206206
super()
207207
this.options = options
208-
let region = this.options.awsRegion
208+
const region = this.options.awsRegion
209209

210210
// process the various user input options, be opinionated about the intent of the options
211211
// and determine the model to use during inference and for cost calculations
@@ -532,8 +532,11 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
532532
//so that pricing, context window, caching etc have values that can be used
533533
//However, we want to keep the id of the model to be the ID for the router for
534534
//subsequent requests so they are sent back through the router
535-
let invokedArnInfo = this.parseArn(streamEvent.trace.promptRouter.invokedModelId)
536-
let invokedModel = this.getModelById(invokedArnInfo.modelId as string, invokedArnInfo.modelType)
535+
const invokedArnInfo = this.parseArn(streamEvent.trace.promptRouter.invokedModelId)
536+
const invokedModel = this.getModelById(
537+
invokedArnInfo.modelId as string,
538+
invokedArnInfo.modelType,
539+
)
537540
if (invokedModel) {
538541
invokedModel.id = modelConfig.id
539542
this.costModelConfig = invokedModel
@@ -870,7 +873,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
870873
}
871874

872875
// Get cache point placements
873-
let strategy = new MultiPointStrategy(config)
876+
const strategy = new MultiPointStrategy(config)
874877
const cacheResult = strategy.determineOptimalCachePoints()
875878

876879
// Store cache point placements for future use if conversation ID is provided
@@ -934,7 +937,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
934937
*/
935938

936939
const arnRegex = /^arn:[^:]+:(?:bedrock|sagemaker):([^:]+):([^:]*):(?:([^\/]+)\/([\w\.\-:]+)|([^\/]+))$/
937-
let match = arn.match(arnRegex)
940+
const match = arn.match(arnRegex)
938941

939942
if (match && match[1] && match[3] && match[4]) {
940943
// Create the result object
@@ -961,7 +964,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
961964
// Check if the original model ID had a region prefix
962965
if (originalModelId && result.modelId !== originalModelId) {
963966
// If the model ID changed after parsing, it had a region prefix
964-
let prefix = originalModelId.replace(result.modelId, "")
967+
const prefix = originalModelId.replace(result.modelId, "")
965968
result.crossRegionInference = AwsBedrockHandler.isSystemInferenceProfile(prefix)
966969
}
967970

src/api/providers/fake-ai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface FakeAI {
3838
*
3939
* We use the ID to lookup the original FakeAI object in the mapping.
4040
*/
41-
let fakeAiMap: Map<string, FakeAI> = new Map()
41+
const fakeAiMap: Map<string, FakeAI> = new Map()
4242

4343
export class FakeAIHandler implements ApiHandler, SingleCompletionHandler {
4444
private ai: FakeAI

src/api/providers/fetchers/ollama.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export async function getOllamaModels(
8181

8282
const response = await axios.get<OllamaModelsResponse>(`${baseUrl}/api/tags`, { headers })
8383
const parsedResponse = OllamaModelsResponseSchema.safeParse(response.data)
84-
let modelInfoPromises = []
84+
const modelInfoPromises = []
8585

8686
if (parsedResponse.success) {
8787
for (const ollamaModel of parsedResponse.data.models) {

src/api/providers/gemini.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
348348

349349
override getModel() {
350350
const modelId = this.options.apiModelId
351-
let id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId
351+
const id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId
352352
let info: ModelInfo = geminiModels[id]
353353

354354
const params = getModelParams({
@@ -509,7 +509,7 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
509509
// Bill both completion and reasoning ("thoughts") tokens as output.
510510
const billedOutputTokens = outputTokens + reasoningTokens
511511

512-
let cacheReadCost = cacheReadTokens > 0 ? cacheReadsPrice * (cacheReadTokens / 1_000_000) : 0
512+
const cacheReadCost = cacheReadTokens > 0 ? cacheReadsPrice * (cacheReadTokens / 1_000_000) : 0
513513

514514
const inputTokensCost = inputPrice * (uncachedInputTokens / 1_000_000)
515515
const outputTokensCost = outputPrice * (billedOutputTokens / 1_000_000)

src/api/providers/lite-llm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa
184184
}
185185

186186
// Required by some providers; others default to max tokens allowed
187-
let maxTokens: number | undefined = info.maxTokens ?? undefined
187+
const maxTokens: number | undefined = info.maxTokens ?? undefined
188188

189189
// Check if this is a GPT-5 model that requires max_completion_tokens instead of max_tokens
190190
const isGPT5Model = this.isGpt5(modelId)

src/api/providers/minimax.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export class MiniMaxHandler extends BaseProvider implements SingleCompletionHand
8181
messages: Anthropic.Messages.MessageParam[],
8282
metadata?: ApiHandlerCreateMessageMetadata,
8383
): ApiStream {
84-
let stream: AnthropicStream<Anthropic.Messages.RawMessageStreamEvent>
8584
const cacheControl: CacheControlEphemeral = { type: "ephemeral" }
8685
const { id: modelId, info, maxTokens, temperature } = this.getModel()
8786

@@ -113,7 +112,7 @@ export class MiniMaxHandler extends BaseProvider implements SingleCompletionHand
113112
tool_choice: convertOpenAIToolChoice(metadata?.tool_choice),
114113
}
115114

116-
stream = await this.client.messages.create(requestParams)
115+
const stream = await this.client.messages.create(requestParams)
117116

118117
let inputTokens = 0
119118
let outputTokens = 0

src/api/providers/openai-codex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ export class OpenAiCodexHandler extends BaseProvider implements SingleCompletion
11171117
override getModel() {
11181118
const modelId = this.options.apiModelId
11191119

1120-
let id = modelId && modelId in openAiCodexModels ? (modelId as OpenAiCodexModelId) : openAiCodexDefaultModelId
1120+
const id = modelId && modelId in openAiCodexModels ? (modelId as OpenAiCodexModelId) : openAiCodexDefaultModelId
11211121

11221122
const info: ModelInfo = openAiCodexModels[id]
11231123

src/api/providers/openai-native.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
674674
const decoder = new TextDecoder()
675675
let buffer = ""
676676
let hasContent = false
677-
let totalInputTokens = 0
678-
let totalOutputTokens = 0
677+
const totalInputTokens = 0
678+
const totalOutputTokens = 0
679679

680680
try {
681681
while (true) {
@@ -1435,7 +1435,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
14351435
override getModel() {
14361436
const modelId = this.options.apiModelId
14371437

1438-
let id =
1438+
const id =
14391439
modelId && modelId in openAiNativeModels ? (modelId as OpenAiNativeModelId) : openAiNativeDefaultModelId
14401440

14411441
const info: ModelInfo = openAiNativeModels[id]

0 commit comments

Comments
 (0)