Skip to content

Commit c206c06

Browse files
committed
Added linter to project, fixed all linter errors (~260). Should be no functional changes.
1 parent d89d50f commit c206c06

73 files changed

Lines changed: 839 additions & 753 deletions

Some content is hidden

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

.github/workflows/main.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v6
1616

17-
- name: Check formatting
18-
run: npx prettier --check .
19-
2017
- uses: actions/setup-node@v6
2118
with:
2219
node-version-file: package.json
@@ -29,15 +26,14 @@ jobs:
2926
- name: Check version consistency
3027
run: npm run check-version
3128

32-
- name: Check linting
33-
working-directory: ./web
29+
- name: Lint
3430
run: npm run lint
3531

36-
- name: Run web tests
37-
working-directory: ./web
38-
run: npm test
32+
- name: Build
33+
run: npm run build
3934

40-
- run: npm run build
35+
- name: Run tests
36+
run: npm test
4137

4238
publish:
4339
runs-on: ubuntu-latest

cli/__tests__/cli.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, beforeAll, afterAll, expect } from "vitest";
1+
import { describe, it, expect } from "vitest";
22
import { runCli } from "./helpers/cli-runner.js";
33
import {
44
expectCliSuccess,
@@ -37,7 +37,7 @@ describe("CLI Tests", () => {
3737
expect(Array.isArray(json.tools)).toBe(true);
3838

3939
// Validate expected tools from test-mcp-server
40-
const toolNames = json.tools.map((tool: any) => tool.name);
40+
const toolNames = json.tools.map((tool: { name: string }) => tool.name);
4141
expect(toolNames).toContain("echo");
4242
expect(toolNames).toContain("get_sum");
4343
expect(toolNames).toContain("get_annotated_message");
@@ -381,7 +381,7 @@ describe("CLI Tests", () => {
381381
});
382382

383383
try {
384-
const port = await server.start();
384+
await server.start();
385385
const result = await runCli([
386386
server.url,
387387
"--cli",
@@ -550,7 +550,6 @@ describe("CLI Tests", () => {
550550
"test-sse": {
551551
type: "sse",
552552
url: "http://localhost:3000/sse",
553-
note: "Test SSE server",
554553
},
555554
},
556555
});
@@ -577,7 +576,6 @@ describe("CLI Tests", () => {
577576
"test-http": {
578577
type: "streamable-http",
579578
url: "http://localhost:3001/mcp",
580-
note: "Test HTTP server",
581579
},
582580
},
583581
});

cli/__tests__/headers.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("Header Parsing and Validation", () => {
2020
});
2121

2222
try {
23-
const port = await server.start();
23+
await server.start();
2424
const result = await runCli([
2525
server.url,
2626
"--cli",
@@ -58,7 +58,7 @@ describe("Header Parsing and Validation", () => {
5858
});
5959

6060
try {
61-
const port = await server.start();
61+
await server.start();
6262
const result = await runCli([
6363
server.url,
6464
"--cli",
@@ -91,7 +91,7 @@ describe("Header Parsing and Validation", () => {
9191
});
9292

9393
try {
94-
const port = await server.start();
94+
await server.start();
9595
const result = await runCli([
9696
server.url,
9797
"--cli",
@@ -123,7 +123,7 @@ describe("Header Parsing and Validation", () => {
123123
});
124124

125125
try {
126-
const port = await server.start();
126+
await server.start();
127127
const result = await runCli([
128128
server.url,
129129
"--cli",

cli/__tests__/helpers/cli-runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export async function runCli(
5454
// On Unix, kill the process group
5555
process.kill(-child.pid!, "SIGTERM");
5656
}
57-
} catch (e) {
57+
} catch {
5858
// Process might already be dead, try direct kill
5959
try {
6060
child.kill("SIGKILL");
61-
} catch (e2) {
61+
} catch {
6262
// Process is definitely dead
6363
}
6464
}

cli/__tests__/helpers/fixtures.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from "path";
33
import * as os from "os";
44
import * as crypto from "crypto";
55
import { getTestMcpServerCommand } from "@modelcontextprotocol/inspector-test-server";
6+
import type { MCPServerConfig } from "@modelcontextprotocol/inspector-core/mcp/index.js";
67

78
/**
89
* Sentinel value for tests that don't need a real server
@@ -54,7 +55,7 @@ function createTempDir(prefix: string = "mcp-inspector-test-"): string {
5455
function cleanupTempDir(dir: string) {
5556
try {
5657
fs.rmSync(dir, { recursive: true, force: true });
57-
} catch (err) {
58+
} catch {
5859
// Ignore cleanup errors
5960
}
6061
}
@@ -63,7 +64,7 @@ function cleanupTempDir(dir: string) {
6364
* Create a test config file
6465
*/
6566
export function createTestConfig(config: {
66-
mcpServers: Record<string, any>;
67+
mcpServers: Record<string, MCPServerConfig>;
6768
}): string {
6869
const tempDir = createTempDir("mcp-inspector-config-");
6970
const configPath = path.join(tempDir, "config.json");

cli/__tests__/tools.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("Tool Tests", () => {
2929
expect(json.tools[0]).toHaveProperty("name");
3030
expect(json.tools[0]).toHaveProperty("description");
3131
// Validate expected tools from test-mcp-server
32-
const toolNames = json.tools.map((tool: any) => tool.name);
32+
const toolNames = json.tools.map((tool: { name: string }) => tool.name);
3333
expect(toolNames).toContain("echo");
3434
expect(toolNames).toContain("get_sum");
3535
expect(toolNames).toContain("get_annotated_message");
@@ -133,7 +133,9 @@ describe("Tool Tests", () => {
133133
expect(Array.isArray(json.content)).toBe(true);
134134
// Should have both text and image content
135135
expect(json.content.length).toBeGreaterThan(1);
136-
const hasImage = json.content.some((item: any) => item.type === "image");
136+
const hasImage = json.content.some(
137+
(item: { type?: string }) => item.type === "image",
138+
);
137139
expect(hasImage).toBe(true);
138140
});
139141

@@ -157,7 +159,9 @@ describe("Tool Tests", () => {
157159
expect(json).toHaveProperty("content");
158160
expect(Array.isArray(json.content)).toBe(true);
159161
// Should only have text content, no image
160-
const hasImage = json.content.some((item: any) => item.type === "image");
162+
const hasImage = json.content.some(
163+
(item: { type?: string }) => item.type === "image",
164+
);
161165
expect(hasImage).toBe(false);
162166
// test-mcp-server returns "This is a {messageType} message"
163167
expect(json.content[0].text.toLowerCase()).toContain("error");

cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"scripts": {
1818
"build": "tsc",
1919
"postbuild": "node scripts/make-executable.js",
20+
"lint": "prettier --check . && eslint . --max-warnings 0 && echo 'Lint passed.'",
2021
"test": "vitest run",
2122
"test:watch": "vitest",
2223
"test:cli": "vitest run cli.test.ts",

cli/src/cli.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ function handleError(error: unknown): never {
6969
process.exit(1);
7070
}
7171

72-
function delay(ms: number): Promise<void> {
73-
return new Promise((resolve) => setTimeout(resolve, ms, true));
74-
}
75-
7672
async function runWeb(args: Args): Promise<void> {
7773
// Path to the web entry point
7874
const inspectorWebPath = resolve(

cli/src/index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ async function callMethod(args: Args): Promise<void> {
164164
// Read package.json to get name and version for client identity
165165
const pathA = "../package.json"; // We're in package @modelcontextprotocol/inspector-cli
166166
const pathB = "../../package.json"; // We're in package @modelcontextprotocol/inspector
167-
let packageJson: { name: string; version: string };
168-
let packageJsonData = await import(fs.existsSync(pathA) ? pathA : pathB, {
167+
const packageJsonData = await import(fs.existsSync(pathA) ? pathA : pathB, {
169168
with: { type: "json" },
170169
});
171-
packageJson = packageJsonData.default;
170+
const packageJson = packageJsonData.default as {
171+
name: string;
172+
version: string;
173+
};
172174

173175
const [, name = packageJson.name] = packageJson.name.split("/");
174176
const version = packageJson.version;
@@ -285,11 +287,7 @@ async function callMethod(args: Args): Promise<void> {
285287

286288
await awaitableLog(JSON.stringify(result, null, 2));
287289
} finally {
288-
try {
289-
await inspectorClient.disconnect();
290-
} catch (disconnectError) {
291-
throw disconnectError;
292-
}
290+
await inspectorClient.disconnect();
293291
}
294292
}
295293

@@ -458,7 +456,7 @@ function parseArgs(): Args {
458456
toolMetadata?: Record<string, JsonValue>;
459457
};
460458

461-
let remainingArgs = program.args;
459+
const remainingArgs = program.args;
462460

463461
// Add back any arguments that came after --
464462
const finalArgs = [...remainingArgs, ...postArgs];

core/__tests__/auth/providers.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ describe("OAuthNavigation", () => {
3737

3838
describe("BrowserNavigation", () => {
3939
// Mock window.location for Node.js environment
40-
const originalWindow = global.window;
40+
type GlobalWithWindow = typeof globalThis & {
41+
window?: { location: { href: string } };
42+
};
43+
const originalWindow = (global as GlobalWithWindow).window;
4144

4245
beforeEach(() => {
43-
(global as any).window = {
44-
location: {
45-
href: "http://localhost:5173",
46-
},
47-
};
46+
(global as GlobalWithWindow).window = {
47+
location: { href: "http://localhost:5173" },
48+
} as GlobalWithWindow["window"];
4849
});
4950

5051
afterEach(() => {
51-
global.window = originalWindow;
52+
(global as GlobalWithWindow).window = originalWindow;
5253
});
5354

5455
it("should set window.location.href to authorization URL", () => {
@@ -57,11 +58,14 @@ describe("OAuthNavigation", () => {
5758

5859
navigation.navigateToAuthorization(authUrl);
5960

60-
expect((global as any).window.location.href).toBe(authUrl.toString());
61+
expect((global as GlobalWithWindow).window!.location.href).toBe(
62+
authUrl.toString(),
63+
);
6164
});
6265

6366
it("should throw error in non-browser environment", () => {
64-
delete (global as any).window;
67+
(global as GlobalWithWindow).window =
68+
undefined as unknown as GlobalWithWindow["window"];
6569
const navigation = new BrowserNavigation();
6670
const authUrl = new URL("http://example.com/authorize");
6771

0 commit comments

Comments
 (0)