Files
siftlode/frontend/src/lib/jsxCommentText.contract.test.ts
T
peter ff80cc96fd fix(design): rating and live colour tokens, the player's menus over its notices, the info overlay on a light theme (E28)
- F16: --rating (theme-scoped gold, 4.5:1 on the page and its chip), --rating-media, --live/--live-fg,
  --media-chrome replace 14 palette literals; a lint rule refuses palette classes; the theme contract
  measures them.
- The Plex player's notices drew over its open settings/tracks popovers: notices z-base, popovers z-menu.
- The player's info overlay rendered theme tokens on its always-dark panel: on a light theme the score
  (2.6:1), collection years (3.2:1) and cast initials (1.05:1) were unreadable; onDark variants now.
- The lint-rule contract tests share one ESLint with a one-off warm-up (a cold first lint took 8 s,
  past vitest's 5 s).
2026-09-25 13:55:26 +02:00

28 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { eslint } from "./lintProbe.testkit";
// `local/jsx-comment-text` (eslint.config.js): a `//` inside JSX children is rendered as text. One
// reached the Playlists page past tsc, eslint and every test — only a visual check caught it. A rule
// that matches nothing looks exactly like a clean codebase, so this asserts it fires.
const RULE = "local/jsx-comment-text";
async function hits(source: string): Promise<number> {
const [result] = await eslint.lintText(source, { filePath: "src/components/__probe.tsx" });
return (result?.messages ?? []).filter((m) => m.ruleId === RULE).length;
}
describe("a comment inside JSX children", () => {
it("is refused — it would render as text", async () => {
expect(
await hits(`export const A = () => (\n <>\n // the list\n <ul />\n </>\n);\n`),
).toBe(1);
expect(await hits(`export const B = () => <div>/* note */</div>;\n`)).toBe(1);
});
it("is fine as a real comment, and text that merely contains a slash pair is text", async () => {
expect(await hits(`export const C = () => <div>{/* the list */}</div>;\n`)).toBe(0);
expect(await hits(`export const D = () => <p>See https://example.com</p>;\n`)).toBe(0);
});
});