Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-mcp/src/agent/query-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
1 change: 0 additions & 1 deletion apps/docs-mcp/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"strict": true,
"target": "ESNext",
"lib": ["ESNext", "WebWorker"],
"jsx": "react-jsx",
Expand Down
10 changes: 5 additions & 5 deletions apps/games-api/src/leaderboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -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",
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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 () => {
Expand Down
5 changes: 1 addition & 4 deletions apps/games-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
9 changes: 0 additions & 9 deletions apps/local/.oxlintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion apps/local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 5 additions & 7 deletions apps/local/src/App.capture-lifecycle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLButtonElement>("button", {
name: "Reload capture",
exact: true,
}).disabled,
).toBe(false);
expect(request).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -585,7 +583,7 @@ test.each(["connecting", "failed"] as const)(
),
);
expect(
(screen.getByLabelText("Receiver endpoint") as HTMLInputElement).value,
screen.getByLabelText<HTMLInputElement>("Receiver endpoint").value,
).toBe("http://127.0.0.1:8970/stream");
expect(ControllableEventSource.instances).toHaveLength(attempts);
},
Expand Down
34 changes: 15 additions & 19 deletions apps/local/src/App.integration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() =>
Expand All @@ -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();
Expand Down Expand Up @@ -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",
);
Expand Down Expand Up @@ -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<HTMLButtonElement>("button", {
name: "Reconnect",
exact: true,
}).disabled,
).toBe(false);
fireEvent.click(
screen.getByRole("button", { name: "Reconnect", exact: true }),
Expand Down Expand Up @@ -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<HTMLInputElement>("Receiver endpoint").value,
).toBe("http://127.0.0.1:8969/stream");
fireEvent.click(
screen.getByRole("button", { name: "Connect", exact: true }),
Expand Down Expand Up @@ -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<HTMLButtonElement>("button", { name: "Connect" })
.disabled,
).toBe(false);
} finally {
Expand Down Expand Up @@ -1794,14 +1792,14 @@ describe("local receiver to viewer integration", () => {
);
expect(
(
(await settings.findByRole("button", {
await settings.findByRole<HTMLButtonElement>("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<HTMLInputElement>("Envelope limit").value,
).toBe("2000");
expect(retention.getSettings().maxEnvelopes).toBe(1000);
// Await completion, allowing the receiver's five-second request timeout
Expand Down Expand Up @@ -1893,7 +1891,7 @@ describe("local receiver to viewer integration", () => {
);
await waitFor(() =>
expect(
(screen.getByLabelText("Envelope limit") as HTMLInputElement).value,
screen.getByLabelText<HTMLInputElement>("Envelope limit").value,
).toBe("1000"),
);
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
Expand Down Expand Up @@ -2059,7 +2057,7 @@ describe("local receiver to viewer integration", () => {
);
await waitFor(() =>
expect(
(screen.getByLabelText("Envelope limit") as HTMLInputElement).value,
screen.getByLabelText<HTMLInputElement>("Envelope limit").value,
).toBe("1000"),
);
fireEvent.click(
Expand Down Expand Up @@ -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", {
Expand Down
3 changes: 1 addition & 2 deletions apps/local/src/App.sessions.integration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLInputElement>("Envelope limit")).value,
).toBe("500");
expect(
screen.getByRole("button", { name: "Apply envelope limit" }),
Expand Down
1 change: 1 addition & 0 deletions apps/local/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ export default function App() {
<DialogFooter>
<Button
variant="outline"
// oxlint-disable-next-line jsx-a11y/no-autofocus -- destructive confirmations focus Cancel, per the alert dialog pattern
autoFocus
onClick={() => setIsDeleteConfirmationOpen(false)}
>
Expand Down
4 changes: 2 additions & 2 deletions apps/local/src/components/attachment-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ export function AttachmentDetail({
: ` · ${byteLength.toLocaleString()} bytes`}
</p>
{!expanded ? null : !attachment ? (
<p role="status" className="text-sm text-muted-foreground">
<output className="block text-sm text-muted-foreground">
This attachment could not be decoded. Its original payload is
available in JSON.
</p>
</output>
) : content !== undefined ? (
attachment.contentType.includes("json") ? (
<JsonView code={content} />
Expand Down
4 changes: 1 addition & 3 deletions apps/local/src/components/capture-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ export function CaptureHeader({
)}
</div>
<Badge variant={tone} className="shrink-0 font-normal">
<span role="status" aria-label="Capture state">
{state}
</span>
<output aria-label="Capture state">{state}</output>
</Badge>
</div>
{currentSession?.cwd ? (
Expand Down
1 change: 1 addition & 0 deletions apps/local/src/components/event-command-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function EventCommandDialog({
}}
>
<CommandInput
// oxlint-disable-next-line jsx-a11y/no-autofocus -- the command palette opens straight into its search field
autoFocus
aria-label="Search this session"
placeholder="Search events and views"
Expand Down
8 changes: 2 additions & 6 deletions apps/local/src/components/event-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,9 @@ function CompactSummary({
))}
</dl>
{copiedField ? (
<span
role="status"
aria-label={`${copiedField} copied`}
className="sr-only"
>
<output aria-label={`${copiedField} copied`} className="sr-only">
{copiedField} copied
</span>
</output>
) : null}
</>
);
Expand Down
8 changes: 4 additions & 4 deletions apps/local/src/components/json-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export function JsonView({ code }: JsonViewProps) {
<div className="relative">
<div className="absolute top-2 right-3 z-10">{copyButton}</div>
{copied ? (
<span role="status" aria-label="JSON copied" className="sr-only">
<output aria-label="JSON copied" className="sr-only">
JSON copied
</span>
</output>
) : null}
<pre
data-testid="highlighted-json"
Expand All @@ -108,9 +108,9 @@ export function JsonView({ code }: JsonViewProps) {
<div className="relative">
<div className="absolute top-2 right-3 z-10">{copyButton}</div>
{copied ? (
<span role="status" aria-label="JSON copied" className="sr-only">
<output aria-label="JSON copied" className="sr-only">
JSON copied
</span>
</output>
) : null}
<div
data-testid="highlighted-json"
Expand Down
7 changes: 3 additions & 4 deletions apps/local/src/components/local-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ export function LocalSettings({
<p className="text-xs text-muted-foreground">
Applies to all captures in this viewer.
</p>
<div
role="group"
<fieldset
aria-label="Color theme"
className="grid grid-cols-3 gap-2"
className="min-w-0 grid grid-cols-3 gap-2"
>
{THEME_OPTIONS.map(({ value, label, Icon }) => (
<Button
Expand All @@ -95,7 +94,7 @@ export function LocalSettings({
{label}
</Button>
))}
</div>
</fieldset>
</div>
<div className="space-y-3 border-t pt-4">
<h3 className="text-sm font-medium">History capacity</h3>
Expand Down
5 changes: 3 additions & 2 deletions apps/local/src/components/performance-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function ms(value?: number) {
}
function Empty({ children }: { children: string }) {
return (
<p role="status" className="p-6 text-sm text-muted-foreground">
<output className="block p-6 text-sm text-muted-foreground">
{children}
</p>
</output>
);
}
export function SpanAnalysis({
Expand Down Expand Up @@ -306,6 +306,7 @@ export function WebVitalsWorkspace({
</span>
</div>
<div
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- the bar is drawn with child elements, so it can't be an <img>
role="img"
aria-label={`${config.label}: ${valueLabel(measurement.value)}, ${measurement.rating}`}
className="mt-1 h-3 bg-muted"
Expand Down
Loading
Loading