import { describe, expect, it } from "vitest"; import { eslint, uiFiles } from "./lintProbe.testkit"; // `local/button-primitive`'s disabled check (eslint.config.js): a raw `;\n"; describe("a raw button that can be disabled", () => { it("is refused, statically or not", async () => { expect( await hits("export const A = ({ p }: { p: boolean }) => ;\n"), ).toBe(1); expect(await hits("export const B = () => ;\n")).toBe(1); }); it("is refused inside a control primitive and in a test too", async () => { expect(await hits(DISABLED, "src/components/ui/Button.tsx")).toBe(1); // an existing test file: the project service admits only lintProbe.testkit's probe names expect(await hits(DISABLED, "src/modules/feed/Feed.countStale.dom.test.tsx")).toBe(1); }); it("leaves a raw button with no disabled, and the two native-disabled owners, alone", async () => { expect(await hits("export const C = () => ;\n")).toBe(0); expect(await hits(DISABLED, "src/components/ui/FocusSafeButton.tsx")).toBe(0); expect(await hits(DISABLED, "src/components/ui/AnchoredPopover.tsx")).toBe(0); }); // The exemption lives in the rule body, where neither the gate snapshot nor docs/gates.md sees it, // so this holds it to exactly those two: every other file in ui/ is refused. it("is exempt in exactly those two of the ui/ files", { timeout: 60_000 }, async () => { const exempt: string[] = []; for (const file of uiFiles()) if ((await hits(DISABLED, `src/components/ui/${file}`)) === 0) exempt.push(file); expect(exempt).toEqual(["AnchoredPopover.tsx", "FocusSafeButton.tsx"]); }); });