chore(lint): enable no-floating-promises in all five ESLint scopes
A floated promise is invisible at review time — the call reads like an awaited one minus four characters — and the unhandled rejection it produces surfaces in a different test, in a different file, as a stack pointing at SDK internals. In #1947 two un-held `callTool` calls made `npm run ci` unpassable and took a full investigation to attribute; the fix was two lines. `@typescript-eslint/no-floating-promises` catches the class outright, so enable it at `error` everywhere. The rule is type-aware and `tseslint.configs.recommended` is not, so each scope's config gains a parser project. The four clients name their own tsconfig projects (both of them — `src` and `__tests__`/`server` live in different ones). The root scope has no tsconfig at all, so add `tsconfig.lint.json`: a lint-only project covering `core/**`, `test-servers/src/**`, and `vitest.shared.mts`, emitting nothing and gating nothing. It sets `moduleResolution: bundler` deliberately — under NodeNext `core/`'s extensionless imports fail to resolve, every import degrades to `any`, and the rule silently stops seeing promises at all. Measured surface, and the fixes: - core (2) — `stream.close()` in two Hono `onAbort` listeners. Hono invokes subscribers with a bare `subscriber()`, so a promise returned from the listener is floated one layer up; `closeAbortedStream` owns the rejection where it can actually be owned. - tui (5) — `handleDisconnect` had no catch of its own and its only caller is a key handler that cannot await, so a failing disconnect was a live unhandled rejection; it now surfaces the message the way `handleConnect` does. The rest are `void` at callers that genuinely cannot await, over callees that already own their failures. - web (92) — 83 are Storybook `expect(...)`, which is instrumented and returns a promise, now awaited (`scrollAreaStoryAssertions` is async for the same reason). Two tests were asserting against a provider call they never awaited. `open(url)` in both web servers now warns instead of escaping a synchronous callback. - cli, launcher — already clean. Type-aware linting costs time: `clients/web`'s `eslint .` goes from ~8s to ~19s, inside `validate`. Narrowing the loaded projects is the lever if that needs reducing later; dropping the rule is not. Closes #1959 Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
6bc355df63
commit
519ecf49ee
4 changed files with 359 additions and 111 deletions
|
|
@ -69,25 +69,27 @@ type Story = StoryObj<typeof Button>;
|
|||
export const ProjectAnnotationsApplied: Story = {
|
||||
play: async ({ canvasElement, parameters }) => {
|
||||
const canvas = within(canvasElement);
|
||||
expect(canvas.getByRole("button", { name: "Themed" })).toBeInTheDocument();
|
||||
await expect(
|
||||
canvas.getByRole("button", { name: "Themed" }),
|
||||
).toBeInTheDocument();
|
||||
|
||||
const root = getComputedStyle(document.documentElement);
|
||||
|
||||
// `MantineProvider` (the `./preview` decorator) injects the theme's CSS
|
||||
// variables onto `:root`. No provider, no variables.
|
||||
expect(root.getPropertyValue("--mantine-primary-color-filled").trim()).toBe(
|
||||
expectedPrimaryColor(),
|
||||
);
|
||||
await expect(
|
||||
root.getPropertyValue("--mantine-primary-color-filled").trim(),
|
||||
).toBe(expectedPrimaryColor());
|
||||
|
||||
// `--inspector-brand-primary` is defined in `App.css`, which only reaches
|
||||
// the story through `./preview`'s stylesheet import — and it resolves
|
||||
// *through* the Mantine variable above, so this covers both layers.
|
||||
expect(root.getPropertyValue("--inspector-brand-primary").trim()).toBe(
|
||||
expectedPrimaryColor(),
|
||||
);
|
||||
await expect(
|
||||
root.getPropertyValue("--inspector-brand-primary").trim(),
|
||||
).toBe(expectedPrimaryColor());
|
||||
|
||||
// The preview `parameters` merged into the story context — the same channel
|
||||
// that carries `a11y: { test: "error" }` to the a11y addon.
|
||||
expect(parameters.a11y).toMatchObject({ test: "error" });
|
||||
await expect(parameters.a11y).toMatchObject({ test: "error" });
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,12 +117,12 @@ describe("EmaTransportOAuthProvider", () => {
|
|||
expect(await provider.clientInformation()).toEqual({ client_id: "abc" });
|
||||
expect(await provider.codeVerifier()).toBe("verifier-xyz");
|
||||
|
||||
provider.saveClientInformation({ client_id: "new" } as never);
|
||||
await provider.saveClientInformation({ client_id: "new" } as never);
|
||||
expect(inner.saveClientInformation).toHaveBeenCalledWith({
|
||||
client_id: "new",
|
||||
});
|
||||
|
||||
provider.saveCodeVerifier("cv");
|
||||
await provider.saveCodeVerifier("cv");
|
||||
expect(inner.saveCodeVerifier).toHaveBeenCalledWith("cv");
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1588,7 +1588,7 @@ describe("OAuthManager", () => {
|
|||
});
|
||||
|
||||
const provider = await manager.createOAuthProviderForTransport();
|
||||
provider.redirectToAuthorization(
|
||||
await provider.redirectToAuthorization(
|
||||
new URL("https://as.example.com/authorize?client_id=abc&state=xyz"),
|
||||
);
|
||||
|
||||
|
|
@ -1610,7 +1610,7 @@ describe("OAuthManager", () => {
|
|||
});
|
||||
|
||||
const provider = await manager.createOAuthProviderForTransport();
|
||||
provider.redirectToAuthorization(
|
||||
await provider.redirectToAuthorization(
|
||||
new URL("https://as.example.com/authorize?client_id=abc&state=xyz"),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,22 +6,24 @@ import { expect } from "storybook/test";
|
|||
* hidden when idle (`type="scroll"`, so it shows only while scrolling rather
|
||||
* than on hover). Shared by the Protocol/Network/Logging panel stories (#1474).
|
||||
*/
|
||||
export function expectScrollbarGutterIdleHidden(canvasElement: HTMLElement) {
|
||||
export async function expectScrollbarGutterIdleHidden(
|
||||
canvasElement: HTMLElement,
|
||||
) {
|
||||
const viewport = canvasElement.querySelector(".mantine-ScrollArea-viewport");
|
||||
if (!(viewport instanceof HTMLElement)) {
|
||||
throw new Error("scroll viewport not found");
|
||||
}
|
||||
// offsetScrollbars reserves a non-zero inline-end gutter for the scrollbar.
|
||||
const pad = parseFloat(getComputedStyle(viewport).paddingInlineEnd);
|
||||
expect(pad).toBeGreaterThan(0);
|
||||
await expect(pad).toBeGreaterThan(0);
|
||||
// type="scroll" → scrollbars are mounted but hidden until the user scrolls.
|
||||
// Assert at least one exists first so the loop isn't trivially-true if a
|
||||
// future change stops rendering the scrollbar element.
|
||||
const scrollbars = canvasElement.querySelectorAll(
|
||||
".mantine-ScrollArea-scrollbar",
|
||||
);
|
||||
expect(scrollbars.length).toBeGreaterThan(0);
|
||||
await expect(scrollbars.length).toBeGreaterThan(0);
|
||||
for (const bar of scrollbars) {
|
||||
expect(bar.getAttribute("data-state")).toBe("hidden");
|
||||
await expect(bar.getAttribute("data-state")).toBe("hidden");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue