Skip to content

Commit 2fddd73

Browse files
committed
no-mistakes(lint): restore vscode eslint config, clear resulting lint errors
1 parent 6b85db5 commit 2fddd73

10 files changed

Lines changed: 74 additions & 14 deletions

File tree

vscode/.eslintrc.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// ESLint config for the VS Code extension, scoped to this package: the npm
2+
// package next door is plain CommonJS with its own conventions, so `root` stops
3+
// this from reaching it.
4+
//
5+
// The severities below are not a style opinion - each one is set to the level
6+
// at which the rule catches a real defect in THIS codebase, so that
7+
// `npm run lint` failing means something is actually wrong and is worth
8+
// blocking on. Rules that only fire on deliberate, already-idiomatic code are
9+
// turned off with the reason recorded rather than silenced case by case.
10+
{
11+
"root": true,
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"ecmaVersion": 2022,
15+
"sourceType": "module"
16+
},
17+
"plugins": ["@typescript-eslint"],
18+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
19+
"env": {
20+
"node": true,
21+
"es2022": true
22+
},
23+
"ignorePatterns": ["out", "dist", "node_modules", "media", "webview"],
24+
"rules": {
25+
// The `_`-prefix convention this source already follows: a parameter
26+
// named `_token` is one the VS Code API hands us and we deliberately do
27+
// not read, and renaming it would lose which API slot it fills. An
28+
// unprefixed unused binding is still an error, because that is the case
29+
// where something was meant to be used and was not.
30+
"@typescript-eslint/no-unused-vars": [
31+
"error",
32+
{
33+
"argsIgnorePattern": "^_",
34+
"varsIgnorePattern": "^_",
35+
"caughtErrorsIgnorePattern": "^_"
36+
}
37+
],
38+
// `vscode-languageclient` declares its request types as namespaces
39+
// (`namespace Foo { export const type = new RequestType(...) }`) and
40+
// src/views/graphPanel.ts follows that idiom for its own requests. The
41+
// rule is correct in general and wrong for the one pattern our
42+
// dependency prescribes.
43+
"@typescript-eslint/no-namespace": "off",
44+
// Warn, not error: `any` here is concentrated in the boundary code that
45+
// talks to the untyped language-server protocol payloads. Each site is
46+
// a real typing debt worth seeing, but none of them is a defect that
47+
// should stop a build, and typing them properly is a change to the
48+
// protocol surface rather than a lint fix.
49+
"@typescript-eslint/no-explicit-any": "warn"
50+
},
51+
"overrides": [
52+
{
53+
// Test doubles stand in for the `vscode` API, whose shape they must
54+
// match exactly - including the parameters a given test never
55+
// reads and the wide types the real API declares. Enforcing either
56+
// rule here would push the mocks away from the API they imitate.
57+
"files": ["**/*.test.ts"],
58+
"rules": {
59+
"@typescript-eslint/no-explicit-any": "off",
60+
"@typescript-eslint/no-unsafe-function-type": "off",
61+
"@typescript-eslint/no-unused-vars": [
62+
"error",
63+
{ "args": "none", "varsIgnorePattern": "^_" }
64+
]
65+
}
66+
}
67+
]
68+
}

vscode/src/ai/contextProvider.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import { describe, it, expect, beforeEach, vi } from 'vitest';
55
import {
6-
setMock,
76
reset,
87
clearAllMocks,
98
} from '@vsforge/shim';

vscode/src/ai/toolManager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2025-2026 Andrey Vasilevsky <anvanster@gmail.com>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
4+
import { describe, it, expect, beforeEach, vi } from 'vitest';
55
import {
66
reset,
77
clearAllMocks,

vscode/src/ai/toolManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ export class CodeGraphToolManager {
688688

689689
try {
690690
references = await Promise.race([refPromise, timeoutPromise]);
691-
} catch (timeoutErr) {
691+
} catch {
692692
// Reference search timed out, continue without references
693693
console.log('[CodeGraph] Reference search timed out, returning partial results');
694694
}

vscode/src/commands/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
clearAllMocks,
1010
} from '@vsforge/shim';
1111
import {
12-
mockActiveTextEditor,
1312
mockConfiguration,
1413
mockQuickPickSelection,
1514
} from '@vsforge/test';

vscode/src/commands/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function registerCommands(
9494
}
9595
};
9696
context.subscriptions.push(vscode.commands.registerCommand(commandId, wrapped));
97-
} catch (error) {
97+
} catch {
9898
console.warn(`Command ${commandId} already registered, skipping`);
9999
}
100100
};
@@ -240,7 +240,7 @@ export function registerCommands(
240240
'CodeGraph: Use @codegraph in the chat to get code context. ' +
241241
'Try: @codegraph explain this function'
242242
);
243-
} catch (error) {
243+
} catch {
244244
// Chat panel not available - show helpful message
245245
vscode.window.showInformationMessage(
246246
'CodeGraph provides AI context via:\n' +

vscode/src/engineDownload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as vscode from 'vscode';
2222
// The canonical implementation lives with the npm package; esbuild follows the
2323
// path and inlines it into out/extension.js, so both JavaScript channels ship
2424
// the same code rather than two implementations that drift.
25-
// eslint-disable-next-line @typescript-eslint/no-var-requires
25+
// eslint-disable-next-line @typescript-eslint/no-require-imports
2626
const fetchEngine = require('../../mcp-package/bin/fetch-engine.js');
2727

2828
/** Where downloaded engines live, shared with the CLI and the JetBrains plugin. */

vscode/src/extension.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
reset,
88
getCalls,
99
clearAllMocks,
10-
vscode,
1110
} from '@vsforge/shim';
1211
import { mockConfiguration } from '@vsforge/test';
1312

vscode/src/extension.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ let lastExitSignal: string | null = null;
4141
const MAX_RAPID_CRASHES = 3;
4242
const RAPID_CRASH_WINDOW_MS = 60_000;
4343
let rapidCrashTimestamps: number[] = [];
44-
let crashLoopDetected = false;
4544
// Set true right before an intentional server stop (crash-loop give-up,
4645
// deactivate) so the onDidChangeState→Stopped that follows isn't logged
4746
// as a crash. Consume-once: the handler resets it after skipping.
@@ -468,7 +467,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
468467
else if (lower.includes('spawn')) errorHint = 'spawn_error';
469468
else {
470469
// Last resort: first 80 chars, strip anything that looks like a path
471-
errorHint = errStr.substring(0, 80).replace(/[\/\\][^\s:]+/g, '<path>');
470+
errorHint = errStr.substring(0, 80).replace(/[/\\][^\s:]+/g, '<path>');
472471
}
473472

474473
reporter.activationServerStartResult({
@@ -518,7 +517,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
518517
);
519518

520519
if (rapidCrashTimestamps.length >= MAX_RAPID_CRASHES) {
521-
crashLoopDetected = true;
522520
expectedShutdown = true;
523521
client.stop().catch(() => {});
524522
vscode.window
@@ -531,7 +529,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
531529
)
532530
.then((choice) => {
533531
if (choice === 'Retry') {
534-
crashLoopDetected = false;
535532
rapidCrashTimestamps = [];
536533
serverRestartCount = 0;
537534
client.start().catch(() => {});

vscode/src/telemetry/reporter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { PostHog } from 'posthog-node';
2929

3030
import {
3131
type ActivationOutcome,
32-
type CommandId,
3332
categorizeError,
3433
type ErrorCategory,
3534
type FirstIndexCta,
@@ -51,7 +50,6 @@ import {
5150
normalizeAntivirusKind,
5251
type ServerRestartReason,
5352
SETTINGS_SNAPSHOT_KEYS,
54-
type ToolName,
5553
type TreeView,
5654
} from './allowlists';
5755
import {

0 commit comments

Comments
 (0)