From 296120add16efd88d5b1ccc3f11499f75823b070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Fri, 13 Nov 2026 10:30:21 -0500 Subject: [PATCH] ref(tsconfig): Apply the same strictness everywhere except mcp-core Co-Authored-By: Claude Opus 5.5 --- .oxlintrc.json | 11 ++++++ apps/docs-mcp/src/agent/query-agent.ts | 2 +- apps/docs-mcp/tsconfig.json | 1 - apps/games-api/src/leaderboard.test.ts | 10 +++--- apps/games-api/tsconfig.json | 5 +-- apps/local/.oxlintrc.json | 9 ----- apps/local/package.json | 2 +- apps/local/src/App.capture-lifecycle.test.tsx | 12 +++---- apps/local/src/App.integration.test.tsx | 34 ++++++++----------- .../src/App.sessions.integration.test.tsx | 3 +- apps/local/src/App.tsx | 1 + .../src/components/attachment-detail.tsx | 4 +-- apps/local/src/components/capture-header.tsx | 4 +-- .../src/components/event-command-dialog.tsx | 1 + apps/local/src/components/event-detail.tsx | 8 ++--- apps/local/src/components/json-view.tsx | 8 ++--- apps/local/src/components/local-settings.tsx | 7 ++-- .../src/components/performance-workspace.tsx | 5 +-- .../src/components/profile-workspace.tsx | 10 +++--- .../src/components/receiver-controls.tsx | 3 +- .../src/components/resizable-workspace.tsx | 1 + .../components/retention-settings.test.tsx | 22 +++++------- .../local/src/components/session-switcher.tsx | 5 +-- apps/local/src/components/span-detail.tsx | 8 ++--- apps/local/src/components/trace-waterfall.tsx | 12 +++---- apps/local/src/components/trace-workspace.tsx | 8 ++--- apps/local/src/tsconfig.json | 8 +++++ apps/local/tsconfig.app.json | 5 ++- apps/local/tsconfig.node.json | 3 +- packages/cli/tsconfig.json | 6 +--- packages/codemod-cli3to4/tsconfig.json | 5 +-- packages/logger/tsconfig.json | 2 -- .../animation/TerminalAnimation.tsx | 2 +- .../components/ui/slash-command-text.tsx | 2 +- .../mcp-cloudflare/src/homepage-content.ts | 2 +- .../src/server/lib/approval-dialog.ts | 9 +++-- .../src/server/lib/mcp-handler.ts | 2 +- .../src/server/oauth/resource-scope.ts | 22 +++--------- packages/mcp-cloudflare/tsconfig.client.json | 3 -- packages/mcp-cloudflare/tsconfig.node.json | 3 -- packages/mcp-core/tsconfig.json | 4 +-- packages/mcp-server-evals/tsconfig.json | 3 -- packages/mcp-server-mocks/tsconfig.json | 3 -- packages/mcp-test-client/src/agent.ts | 3 +- packages/mcp-test-client/tsconfig.json | 3 -- packages/toolkit-core/tsconfig.json | 2 -- tsconfig.base.json | 7 +++- 47 files changed, 124 insertions(+), 171 deletions(-) delete mode 100644 apps/local/.oxlintrc.json create mode 100644 apps/local/src/tsconfig.json diff --git a/.oxlintrc.json b/.oxlintrc.json index 509f9e488..5774f6ad1 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -62,6 +62,17 @@ "typescript/unbound-method": "off" } }, + { + "files": ["apps/local/**/*.{ts,tsx,js,mjs,cjs}"], + "plugins": ["react"], + "rules": { + "react/rules-of-hooks": "error", + "react/only-export-components": [ + "warn", + { "allowConstantExport": true } + ] + } + }, { "files": ["packages/mcp-cloudflare/src/client/**/*.tsx"], "rules": { diff --git a/apps/docs-mcp/src/agent/query-agent.ts b/apps/docs-mcp/src/agent/query-agent.ts index 6e3af3806..351154524 100644 --- a/apps/docs-mcp/src/agent/query-agent.ts +++ b/apps/docs-mcp/src/agent/query-agent.ts @@ -81,7 +81,7 @@ export function finalizeDocsAnswer( const body = answer.replace(SOURCES_SECTION_RE, "").trim(); const citations = uniqueCanonicalDocsUrls( - [...body.matchAll(MARKDOWN_LINK_URL_RE)].map((match) => match[1]), + [...body.matchAll(MARKDOWN_LINK_URL_RE)].map((match) => match[1]!), ); if (citations.length === 0) { throw new Error("Docs query answer must include an inline citation."); diff --git a/apps/docs-mcp/tsconfig.json b/apps/docs-mcp/tsconfig.json index d915be489..7be5af381 100644 --- a/apps/docs-mcp/tsconfig.json +++ b/apps/docs-mcp/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "target": "ESNext", "lib": ["ESNext", "WebWorker"], "jsx": "react-jsx", diff --git a/apps/games-api/src/leaderboard.test.ts b/apps/games-api/src/leaderboard.test.ts index 7032343e6..4d76ee4ca 100644 --- a/apps/games-api/src/leaderboard.test.ts +++ b/apps/games-api/src/leaderboard.test.ts @@ -103,7 +103,7 @@ describe("games leaderboard route", () => { }); expect(fetchMock).toHaveBeenCalledTimes(1); - const [url, init] = fetchMock.mock.calls[0]; + const [url, init] = fetchMock.mock.calls[0]!; const parsed = new URL(url as string); expect(parsed.origin + parsed.pathname).toBe( "https://us.sentry.io/api/0/organizations/sentry/events/", @@ -125,7 +125,7 @@ describe("games leaderboard route", () => { }); expect(cachePut).toHaveBeenCalledTimes(1); - const [key, cachedResponse] = cachePut.mock.calls[0]; + const [key, cachedResponse] = cachePut.mock.calls[0]!; expect(key).toBe(CACHE_URL); expect((cachedResponse as Response).headers.get("Cache-Control")).toBe( "max-age=300", @@ -211,7 +211,7 @@ describe("games leaderboard route", () => { expect(res.status).toBe(502); expect(text).not.toContain("secret-upstream-detail"); expect(text).not.toContain(TOKEN); - const reported = vi.mocked(Sentry.captureException).mock.calls[0][0]; + const reported = vi.mocked(Sentry.captureException).mock.calls[0]![0]; expect(String(reported)).toContain("Snake leaderboard upstream failed"); expect(String(reported)).not.toContain(TOKEN); }); @@ -243,8 +243,8 @@ describe("games leaderboard route", () => { it("uses a hashed IP rate limit key", async () => { const limit = vi.fn().mockResolvedValue({ success: false }); await app.request(PATH, REQ, makeEnv({ GAMES_RATE_LIMITER: { limit } })); - expect(limit.mock.calls[0][0].key).toMatch(/^games:ip:[a-f0-9]{16}$/); - expect(limit.mock.calls[0][0].key).not.toContain("192.0.2.1"); + expect(limit.mock.calls[0]![0].key).toMatch(/^games:ip:[a-f0-9]{16}$/); + expect(limit.mock.calls[0]![0].key).not.toContain("192.0.2.1"); }); it("fails open when the rate limiter throws", async () => { diff --git a/apps/games-api/tsconfig.json b/apps/games-api/tsconfig.json index 50fe6f5ba..6c9736edc 100644 --- a/apps/games-api/tsconfig.json +++ b/apps/games-api/tsconfig.json @@ -1,12 +1,9 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ES2023", "ES2024.String"], "types": ["@cloudflare/workers-types"], - "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true + "allowJs": true }, "include": ["src"] } diff --git a/apps/local/.oxlintrc.json b/apps/local/.oxlintrc.json deleted file mode 100644 index 72cf41a39..000000000 --- a/apps/local/.oxlintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "./node_modules/oxlint/configuration_schema.json", - "plugins": ["react", "typescript", "oxc"], - "rules": { - "react/rules-of-hooks": "error", - "typescript/return-await": ["error", "always"], - "react/only-export-components": ["warn", { "allowConstantExport": true }] - } -} diff --git a/apps/local/package.json b/apps/local/package.json index 6f27dcc8f..5e4d07877 100644 --- a/apps/local/package.json +++ b/apps/local/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "vite", "build": "tsc -b && vite build", - "lint": "oxlint", + "lint": "pnpm -w exec oxlint --report-unused-disable-directives apps/local", "preview": "vite preview", "test": "pnpm --filter sentry exec node script/ensure-generated.mjs schema grammar && vitest run", "test:integration": "pnpm run test src/App.integration.test.tsx", diff --git a/apps/local/src/App.capture-lifecycle.test.tsx b/apps/local/src/App.capture-lifecycle.test.tsx index f4eec10a6..2ea5c03ed 100644 --- a/apps/local/src/App.capture-lifecycle.test.tsx +++ b/apps/local/src/App.capture-lifecycle.test.tsx @@ -393,12 +393,10 @@ test("pending deletion disables Reload capture and ignores queued events until c "before pending reset", ); expect( - ( - screen.getByRole("button", { - name: "Reload capture", - exact: true, - }) as HTMLButtonElement - ).disabled, + screen.getByRole("button", { + name: "Reload capture", + exact: true, + }).disabled, ).toBe(false); expect(request).toHaveBeenCalledTimes(1); }); @@ -585,7 +583,7 @@ test.each(["connecting", "failed"] as const)( ), ); expect( - (screen.getByLabelText("Receiver endpoint") as HTMLInputElement).value, + screen.getByLabelText("Receiver endpoint").value, ).toBe("http://127.0.0.1:8970/stream"); expect(ControllableEventSource.instances).toHaveLength(attempts); }, diff --git a/apps/local/src/App.integration.test.tsx b/apps/local/src/App.integration.test.tsx index c80bf000e..cfd7d1323 100644 --- a/apps/local/src/App.integration.test.tsx +++ b/apps/local/src/App.integration.test.tsx @@ -540,7 +540,7 @@ describe("local receiver to viewer integration", () => { expect(detail.textContent).not.toContain("No additional event details."); const frames = screen.getAllByRole("list", { name: "Stack frames" }); expect(frames[0]?.textContent?.indexOf("submitOrder")).toBeLessThan( - frames[0]!.textContent!.indexOf("runMain"), + frames[0]!.textContent.indexOf("runMain"), ); fireEvent.click(screen.getByRole("tab", { name: "JSON" })); await waitFor(() => @@ -549,7 +549,7 @@ describe("local receiver to viewer integration", () => { ), ); expect( - JSON.parse(screen.getByTestId("highlighted-json").textContent!), + JSON.parse(screen.getByTestId("highlighted-json").textContent), ).toEqual({ ...sdkException, type: "event" }); } finally { cleanup(); @@ -715,7 +715,7 @@ describe("local receiver to viewer integration", () => { await sendEnvelope(port, "GET /dock"); await screen.findByLabelText("View transaction event"); const sidebar = screen.getByLabelText("Workspace navigation"); - expect(sidebar.querySelector('[role="status"]')).toBeNull(); + expect(sidebar.querySelector("output")).toBeNull(); expect(screen.getByLabelText("Capture context").textContent).toContain( "Capturing", ); @@ -1222,12 +1222,10 @@ describe("local receiver to viewer integration", () => { screen.getByRole("heading", { name: "No events displayed" }), ).not.toBeNull(); expect( - ( - screen.getByRole("button", { - name: "Reconnect", - exact: true, - }) as HTMLButtonElement - ).disabled, + screen.getByRole("button", { + name: "Reconnect", + exact: true, + }).disabled, ).toBe(false); fireEvent.click( screen.getByRole("button", { name: "Reconnect", exact: true }), @@ -1301,7 +1299,7 @@ describe("local receiver to viewer integration", () => { screen.getByRole("button", { name: "Switch receiver", exact: true }), ); expect( - (screen.getByLabelText("Receiver endpoint") as HTMLInputElement).value, + screen.getByLabelText("Receiver endpoint").value, ).toBe("http://127.0.0.1:8969/stream"); fireEvent.click( screen.getByRole("button", { name: "Connect", exact: true }), @@ -1417,7 +1415,7 @@ describe("local receiver to viewer integration", () => { .textContent, ).toContain("Connection timed out after 10 seconds"); expect( - (screen.getByRole("button", { name: "Connect" }) as HTMLButtonElement) + screen.getByRole("button", { name: "Connect" }) .disabled, ).toBe(false); } finally { @@ -1794,14 +1792,14 @@ describe("local receiver to viewer integration", () => { ); expect( ( - (await settings.findByRole("button", { + await settings.findByRole("button", { name: "Applying…", - })) as HTMLButtonElement + }) ).disabled, ).toBe(true); // The edited input is already 2000 while the HTTP mutation is pending. expect( - (settings.getByLabelText("Envelope limit") as HTMLInputElement).value, + settings.getByLabelText("Envelope limit").value, ).toBe("2000"); expect(retention.getSettings().maxEnvelopes).toBe(1000); // Await completion, allowing the receiver's five-second request timeout @@ -1893,7 +1891,7 @@ describe("local receiver to viewer integration", () => { ); await waitFor(() => expect( - (screen.getByLabelText("Envelope limit") as HTMLInputElement).value, + screen.getByLabelText("Envelope limit").value, ).toBe("1000"), ); fireEvent.click(screen.getByRole("button", { name: "Close", exact: true })); @@ -2059,7 +2057,7 @@ describe("local receiver to viewer integration", () => { ); await waitFor(() => expect( - (screen.getByLabelText("Envelope limit") as HTMLInputElement).value, + screen.getByLabelText("Envelope limit").value, ).toBe("1000"), ); fireEvent.click( @@ -2243,9 +2241,7 @@ describe("local receiver to viewer integration", () => { }); const clearButton = captureAction("Delete captured events"); - await waitFor(() => - expect((clearButton as HTMLButtonElement).disabled).toBe(false), - ); + await waitFor(() => expect(clearButton.disabled).toBe(false)); fireEvent.click(clearButton); fireEvent.click( screen.getByRole("button", { diff --git a/apps/local/src/App.sessions.integration.test.tsx b/apps/local/src/App.sessions.integration.test.tsx index 389fa8d6d..8326e993a 100644 --- a/apps/local/src/App.sessions.integration.test.tsx +++ b/apps/local/src/App.sessions.integration.test.tsx @@ -418,8 +418,7 @@ test("pasting a plain receiver discovers active sessions and waits for newly sta ); await screen.findByRole("dialog", { name: "Settings", exact: true }); expect( - ((await screen.findByLabelText("Envelope limit")) as HTMLInputElement) - .value, + (await screen.findByLabelText("Envelope limit")).value, ).toBe("500"); expect( screen.getByRole("button", { name: "Apply envelope limit" }), diff --git a/apps/local/src/App.tsx b/apps/local/src/App.tsx index 196e30e9d..e70d2507f 100644 --- a/apps/local/src/App.tsx +++ b/apps/local/src/App.tsx @@ -1052,6 +1052,7 @@ export default function App() { {error ? ( -

+ Could not refresh sessions. Your current feed is still available. -

+ ) : null} ); diff --git a/apps/local/src/components/span-detail.tsx b/apps/local/src/components/span-detail.tsx index d16fa7d42..7c201c6d7 100644 --- a/apps/local/src/components/span-detail.tsx +++ b/apps/local/src/components/span-detail.tsx @@ -65,13 +65,9 @@ export function DetailFields({ {copiedField ? ( - + {copiedField} copied - + ) : null} ); diff --git a/apps/local/src/components/trace-waterfall.tsx b/apps/local/src/components/trace-waterfall.tsx index 8c3938f63..3f5485b3c 100644 --- a/apps/local/src/components/trace-waterfall.tsx +++ b/apps/local/src/components/trace-waterfall.tsx @@ -1,3 +1,4 @@ +/* oxlint-disable jsx-a11y/prefer-tag-over-role -- the span tree is an ARIA table laid out with CSS grid */ import { useMemo, useState } from "react"; import { ChevronDown, ChevronRight } from "lucide-react"; import type { TraceGroup, TraceSpan } from "@/lib/trace-model.ts"; @@ -298,13 +299,10 @@ export function TraceWaterfall({ return (
{trace.profileSpansTruncated ? ( -

+ Showing up to 5,000 sampled function spans. Inspect the associated profile for all samples. -

+ ) : null} {compact ? (

{query.trim() ? ( - + {matching.size} matches · branches expanded while searching - + ) : null} ) : null} diff --git a/apps/local/src/components/trace-workspace.tsx b/apps/local/src/components/trace-workspace.tsx index 46daf5a5e..6fcf58755 100644 --- a/apps/local/src/components/trace-workspace.tsx +++ b/apps/local/src/components/trace-workspace.tsx @@ -70,11 +70,11 @@ export function TraceWorkspace({ const previous = previousSpan.current; previousSpan.current = undefined; if (previous.traceId === activeTraceId) { - const button = Array.from( - inspector.current?.querySelectorAll( + const button = [ + ...(inspector.current?.querySelectorAll( "[data-span-id]", - ) ?? [], - ).find((entry) => entry.dataset.spanId === previous.spanId); + ) ?? []), + ].find((entry) => entry.dataset.spanId === previous.spanId); button?.focus(); } } diff --git a/apps/local/src/tsconfig.json b/apps/local/src/tsconfig.json new file mode 100644 index 000000000..da171d155 --- /dev/null +++ b/apps/local/src/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.app.json", + "compilerOptions": { + "types": ["vite/client", "node"] + }, + "include": ["."], + "exclude": [] +} diff --git a/apps/local/tsconfig.app.json b/apps/local/tsconfig.app.json index 9611e02d4..4f7f227ea 100644 --- a/apps/local/tsconfig.app.json +++ b/apps/local/tsconfig.app.json @@ -3,7 +3,7 @@ "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "es2023", - "lib": ["ES2023", "DOM"], + "lib": ["ES2023", "DOM", "DOM.Iterable"], "types": ["vite/client"], "allowArbitraryExtensions": true, @@ -19,8 +19,7 @@ /* Linting */ "noUnusedLocals": true, "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true + "erasableSyntaxOnly": true }, "include": ["src"], "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"] diff --git a/apps/local/tsconfig.node.json b/apps/local/tsconfig.node.json index a2e3655d0..82b379bd0 100644 --- a/apps/local/tsconfig.node.json +++ b/apps/local/tsconfig.node.json @@ -16,8 +16,7 @@ /* Linting */ "noUnusedLocals": true, "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true + "erasableSyntaxOnly": true }, "include": ["vite.config.ts", "scripts/**/*.ts"] } diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index a03877f24..7a70bc778 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -1,17 +1,13 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ESNext"], "target": "ESNext", "allowJs": true, "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "erasableSyntaxOnly": true, - "noEmit": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, - "noImplicitOverride": true + "noEmit": true }, "include": ["src/**/*.ts"], "exclude": ["node_modules", "dist"] diff --git a/packages/codemod-cli3to4/tsconfig.json b/packages/codemod-cli3to4/tsconfig.json index 123ee5921..8d91770c8 100644 --- a/packages/codemod-cli3to4/tsconfig.json +++ b/packages/codemod-cli3to4/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "target": "ESNext", "module": "NodeNext", "moduleResolution": "NodeNext", @@ -10,9 +9,7 @@ "noEmit": true, "verbatimModuleSyntax": true, "erasableSyntaxOnly": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true + "noImplicitReturns": true }, "exclude": ["tests"] } diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json index c3f8e5906..999b11224 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -1,10 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ES2023"], "types": ["node"], - "noUncheckedIndexedAccess": true, "noEmit": true }, "include": ["src/**/*.ts", "test/*.ts"] diff --git a/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx b/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx index 48f5c82b9..c8308c717 100644 --- a/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx +++ b/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx @@ -44,7 +44,7 @@ function getPulseColorClass(index: number): string { } } -const steps: Step[] = [ +const steps: [Step, ...Step[]] = [ { label: "Copypaste Sentry Issue URL", description: "Copy the Sentry issue url directly from your browser", diff --git a/packages/mcp-cloudflare/src/client/components/ui/slash-command-text.tsx b/packages/mcp-cloudflare/src/client/components/ui/slash-command-text.tsx index 9a4f3c199..39452adcf 100644 --- a/packages/mcp-cloudflare/src/client/components/ui/slash-command-text.tsx +++ b/packages/mcp-cloudflare/src/client/components/ui/slash-command-text.tsx @@ -25,7 +25,7 @@ export function SlashCommandText({ match = SLASH_COMMAND_REGEX.exec(children); while (match !== null) { const fullMatch = match[0]; // e.g., "/help" - const command = match[1]; // e.g., "help" + const command = match[1]!; // e.g., "help" const startIndex = match.index; // Add text before the command diff --git a/packages/mcp-cloudflare/src/homepage-content.ts b/packages/mcp-cloudflare/src/homepage-content.ts index 09e7d70c0..8f5362c6d 100644 --- a/packages/mcp-cloudflare/src/homepage-content.ts +++ b/packages/mcp-cloudflare/src/homepage-content.ts @@ -174,7 +174,7 @@ export function generateHomepageFallbackHtml( } else { closeList(); inCodeBlock = true; - codeBlockLang = fence[1].trim(); + codeBlockLang = line.slice(3).trim(); codeLines = []; } continue; diff --git a/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts b/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts index 30a75a76a..0eb7736b5 100644 --- a/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts +++ b/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts @@ -122,9 +122,13 @@ async function getSignedCookiePayload( const cookieValue = getCookieValue(cookieHeader, cookieName); if (!cookieValue) return null; - const parts = cookieValue.split("."); + const [signatureHex, base64Payload, ...extraParts] = cookieValue.split("."); - if (parts.length !== 2) { + if ( + signatureHex === undefined || + base64Payload === undefined || + extraParts.length > 0 + ) { logWarn("Invalid signed cookie format", { loggerScope: ["cloudflare", "approval-dialog"], extra: { cookieName }, @@ -132,7 +136,6 @@ async function getSignedCookiePayload( return null; } - const [signatureHex, base64Payload] = parts; let payload: string; try { payload = atob(base64Payload); diff --git a/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts b/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts index 01a93530a..85bea7844 100644 --- a/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts +++ b/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts @@ -98,7 +98,7 @@ export function getRequestGrantId(request: Request): string | null { if (!auth) return null; const match = auth.match(/^Bearer\s+(.+)$/i); if (!match) return null; - const parts = match[1].split(":"); + const parts = match[1]!.split(":"); if (parts.length !== 3) return null; return parts[1] || null; } diff --git a/packages/mcp-cloudflare/src/server/oauth/resource-scope.ts b/packages/mcp-cloudflare/src/server/oauth/resource-scope.ts index 925f5be66..f47dcf88e 100644 --- a/packages/mcp-cloudflare/src/server/oauth/resource-scope.ts +++ b/packages/mcp-cloudflare/src/server/oauth/resource-scope.ts @@ -11,27 +11,15 @@ export function parseResourceMcpConstraints( try { const { pathname } = new URL(resource); - const pathSegments = pathname.split("/").filter(Boolean); + const [root, organizationSlug, projectSlug, ...extraSegments] = pathname + .split("/") + .filter(Boolean); - if (pathSegments[0] !== "mcp") { + if (root !== "mcp" || !organizationSlug || extraSegments.length > 0) { return null; } - if (pathSegments.length === 2) { - return { - organizationSlug: pathSegments[1], - projectSlug: null, - }; - } - - if (pathSegments.length === 3) { - return { - organizationSlug: pathSegments[1], - projectSlug: pathSegments[2], - }; - } - - return null; + return { organizationSlug, projectSlug: projectSlug ?? null }; } catch { return null; } diff --git a/packages/mcp-cloudflare/tsconfig.client.json b/packages/mcp-cloudflare/tsconfig.client.json index 5e76fc37f..b3722fcf8 100644 --- a/packages/mcp-cloudflare/tsconfig.client.json +++ b/packages/mcp-cloudflare/tsconfig.client.json @@ -1,15 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "target": "ES2020", "lib": ["ES2020", "DOM", "DOM.Iterable"], "types": ["vite/client"], "jsx": "react-jsx", "useDefineForClassFields": true, "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, "sourceMap": true, "declaration": true, "declarationMap": true, diff --git a/packages/mcp-cloudflare/tsconfig.node.json b/packages/mcp-cloudflare/tsconfig.node.json index 2a1294c66..10f3658dd 100644 --- a/packages/mcp-cloudflare/tsconfig.node.json +++ b/packages/mcp-cloudflare/tsconfig.node.json @@ -1,11 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ES2023", "ES2024.String"], "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, "sourceMap": true, "declaration": true, "declarationMap": true, diff --git a/packages/mcp-core/tsconfig.json b/packages/mcp-core/tsconfig.json index 522f59657..1fa90ef72 100644 --- a/packages/mcp-core/tsconfig.json +++ b/packages/mcp-core/tsconfig.json @@ -1,11 +1,9 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, + "noUncheckedIndexedAccess": false, "lib": ["ES2023", "ES2024.String"], "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, "sourceMap": true, "declaration": true, "declarationMap": true, diff --git a/packages/mcp-server-evals/tsconfig.json b/packages/mcp-server-evals/tsconfig.json index 522f59657..4061fbae4 100644 --- a/packages/mcp-server-evals/tsconfig.json +++ b/packages/mcp-server-evals/tsconfig.json @@ -1,11 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ES2023", "ES2024.String"], "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, "sourceMap": true, "declaration": true, "declarationMap": true, diff --git a/packages/mcp-server-mocks/tsconfig.json b/packages/mcp-server-mocks/tsconfig.json index 522f59657..4061fbae4 100644 --- a/packages/mcp-server-mocks/tsconfig.json +++ b/packages/mcp-server-mocks/tsconfig.json @@ -1,11 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ES2023", "ES2024.String"], "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, "sourceMap": true, "declaration": true, "declarationMap": true, diff --git a/packages/mcp-test-client/src/agent.ts b/packages/mcp-test-client/src/agent.ts index 381a5b28b..95be41995 100644 --- a/packages/mcp-test-client/src/agent.ts +++ b/packages/mcp-test-client/src/agent.ts @@ -175,8 +175,7 @@ export async function runAgent( } // Show tool calls with their results - for (let i = 0; i < toolCalls.length; i++) { - const toolCall = toolCalls[i]; + for (const [i, toolCall] of toolCalls.entries()) { const toolResult = toolResults?.[i]; logTool(toolCall.toolName, toolCall.input); diff --git a/packages/mcp-test-client/tsconfig.json b/packages/mcp-test-client/tsconfig.json index 9f0825197..efb3d30c1 100644 --- a/packages/mcp-test-client/tsconfig.json +++ b/packages/mcp-test-client/tsconfig.json @@ -1,11 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, "lib": ["ES2023", "ES2024.String"], "allowJs": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, "sourceMap": true, "declaration": true, "declarationMap": true, diff --git a/packages/toolkit-core/tsconfig.json b/packages/toolkit-core/tsconfig.json index 7495e3bd8..0d7100cbc 100644 --- a/packages/toolkit-core/tsconfig.json +++ b/packages/toolkit-core/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "strict": true, - "noUncheckedIndexedAccess": true, "noEmit": true }, "include": ["src/**/*.ts"] diff --git a/tsconfig.base.json b/tsconfig.base.json index bf775b69a..fd393380f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,6 +9,11 @@ "esModuleInterop": true, "resolveJsonModule": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "noUncheckedIndexedAccess": true, + "noUncheckedSideEffectImports": true } }