Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit 62289c3

Browse files
committed
refactor: clean up unused variables and improve type safety across multiple files
1 parent 2e7e7ca commit 62289c3

13 files changed

Lines changed: 30 additions & 29 deletions

packages/runtime/src/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unused-expressions */
12
// Copyright (c) Microsoft Corporation.
23
// Licensed under the MIT License.
34

@@ -431,4 +432,3 @@ export async function fileTree(
431432
.join("");
432433
}
433434
}
434-

packages/vscode/src/chatparticipant.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { convertAnnotationsToItems } from "../../core/src/annotations";
1717
import { patchCachedImages } from "../../core/src/filecache";
1818
import { deleteUndefinedValues } from "../../core/src/cleaners";
1919

20-
2120
export async function activateChatParticipant(state: ExtensionState) {
2221
const { context } = state;
2322
const { subscriptions } = context;
@@ -47,7 +46,8 @@ export async function activateChatParticipant(state: ExtensionState) {
4746
response: vscode.ChatResponseStream,
4847
token: vscode.CancellationToken,
4948
) => {
50-
let { command, prompt, references, model } = request;
49+
const { command, references, model } = request;
50+
let { prompt } = request;
5151

5252
const md = (t: string, ...enabledCommands: string[]) => {
5353
const ms = new vscode.MarkdownString(t + "\n", true);

packages/vscode/src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import * as vscode from "vscode";
55
import { TOOL_NAME } from "../../core/src/constants";
66
import { errorMessage } from "../../core/src/error";
77

8-
export function registerCommand(id: string, command: (...args: any[]) => Thenable<void>) {
9-
return vscode.commands.registerCommand(id, async function (...args: any[]) {
8+
export function registerCommand(id: string, command: (...args: unknown[]) => Thenable<void>) {
9+
return vscode.commands.registerCommand(id, async function (...args: unknown[]) {
1010
try {
1111
await command(...args);
1212
} catch (e) {

packages/vscode/src/docsnotebook.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface NotebookFrontMatter {
6060
smallModel?: string;
6161
visionModel?: string;
6262
provider?: ModelProviderType;
63-
vars?: Record<string, any>;
63+
vars?: PromptParameters;
6464
files?: string | string[];
6565
}
6666

@@ -120,7 +120,7 @@ function activateNotebookExecutor(state: ExtensionState) {
120120
const fragment: Fragment = {
121121
files: arrayify(files),
122122
};
123-
const parameters = { ...heap, ...vars };
123+
const parameters: PromptParameters = { ...heap, ...vars };
124124
await state.requestAI({
125125
scriptId: template.id,
126126
label: "Executing cell",
@@ -206,7 +206,7 @@ function activateNotebookSerializer(state: ExtensionState) {
206206
const deserializeNotebook: (
207207
data: Uint8Array,
208208
token: vscode.CancellationToken,
209-
) => vscode.NotebookData = (data, token) => {
209+
) => vscode.NotebookData = (data) => {
210210
const decoder = new TextDecoder();
211211
const content = decoder.decode(data);
212212
const cellRawData = parseMarkdown(content);
@@ -243,10 +243,7 @@ function activateNotebookSerializer(state: ExtensionState) {
243243
NOTEBOOK_TYPE,
244244
{
245245
deserializeNotebook,
246-
serializeNotebook: function (
247-
data: vscode.NotebookData,
248-
token: vscode.CancellationToken,
249-
): Uint8Array {
246+
serializeNotebook: function (data: vscode.NotebookData): Uint8Array {
250247
const encoder = new TextEncoder();
251248
const decoder = new TextDecoder();
252249
const { cells } = data;

packages/vscode/src/fs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function checkDirectoryExists(
2525
const file = filePath ? vscode.Uri.joinPath(folderOrFile, filePath) : folderOrFile;
2626
const stat = await vscode.workspace.fs.stat(file);
2727
return stat.type === vscode.FileType.Directory;
28-
} catch (error) {
28+
} catch {
2929
return false;
3030
}
3131
}
@@ -38,7 +38,7 @@ export async function checkFileExists(
3838
const file = filePath ? vscode.Uri.joinPath(folderOrFile, filePath) : folderOrFile;
3939
const stat = await vscode.workspace.fs.stat(file);
4040
return stat.type === vscode.FileType.File;
41-
} catch (error) {
41+
} catch {
4242
return false;
4343
}
4444
}
@@ -83,7 +83,7 @@ export async function readFileJSON<T>(
8383
const src = await readFileText(folder, filePath);
8484
try {
8585
return JSON5TryParse(src);
86-
} catch (e) {
86+
} catch {
8787
return undefined;
8888
}
8989
}

packages/vscode/src/lmaccess.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
/* eslint-disable @typescript-eslint/naming-convention */
54
import * as vscode from "vscode";
65
import { ExtensionState } from "./state";
76
import type { ChatCompletionMessageParam } from "../../core/src/chattypes";
@@ -65,7 +64,10 @@ async function messagesToChatMessages(messages: ChatCompletionMessageParam[]) {
6564
case "assistant":
6665
if (
6766
Array.isArray(m.content) &&
68-
m.content.some((c: any) => typeof c === "object" && "type" in c && c.type === "image_url")
67+
m.content.some(
68+
(c: ChatCompletionMessageParam["content"][0]) =>
69+
typeof c === "object" && "type" in c && c.type === "image_url",
70+
)
6971
)
7072
throw new Error("Vision model not supported");
7173
res.push(
@@ -109,9 +111,7 @@ export function createChatModelRunner(state: ExtensionState): LanguageModelChatR
109111
token,
110112
);
111113

112-
let text = "";
113114
for await (const fragment of request.text) {
114-
text += fragment;
115115
onChunk({
116116
chunk: fragment,
117117
tokens: await chatModel.countTokens(fragment),

packages/vscode/src/markdowndocumentprovider.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ class MarkdownTextDocumentContentProvider implements vscode.TextDocumentContentP
5454
return renderTraceTree(node, 3);
5555
}
5656

57-
async provideTextDocumentContent(
58-
uri: vscode.Uri,
59-
token: vscode.CancellationToken,
60-
): Promise<string> {
57+
async provideTextDocumentContent(uri: vscode.Uri): Promise<string> {
6158
const aiRequest = this.state.aiRequest;
6259
const computing = !!aiRequest?.computing;
6360
const res = aiRequest?.response;

packages/vscode/src/promptcommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function commandButtons(state: ExtensionState) {
113113

114114
export function commandButtonsMarkdown(state: ExtensionState, sep = " | ") {
115115
const res = commandButtons(state)
116-
.map(({ label, description, cmd }) => `[${label}](command:${cmd})`)
116+
.map(({ label, cmd }) => `[${label}](command:${cmd})`)
117117
.join(sep);
118118
return res;
119119
}

packages/vscode/src/prompttree.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ class PromptTreeDataProvider implements vscode.TreeDataProvider<PromptTreeNode>
3434
filename,
3535
title,
3636
description = "",
37+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3738
system = [],
39+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3840
text,
41+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3942
defTools,
43+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4044
jsSource,
4145
...rest
4246
} = element;

packages/vscode/src/servermanager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export class TerminalServerManager extends EventTarget implements ServerManager
163163

164164
private clearTerminalStartWatcher() {
165165
if (this._terminalStartWatcher) {
166+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
166167
clearTimeout(this._terminalStartWatcher as any);
167168
this._terminalStartWatcher = undefined;
168169
}

0 commit comments

Comments
 (0)