build(eslint): drop the Z_RAW and EDGED_LABEL selectors
Both came out of the E28 claim audit (0521149cnamed z-levels,e13d93a3static labels as flat Badges) after the audit itself had fixed the sites. No real hit since: 0 matches in every lint run from E28 to E34 (S2/S3 measurement). Each still cost a probe test (zLayer.contract, the edged-label half of hoverAndLink.contract) and a place in the gate snapshot. The design rules stay in DESIGN.md (Tokens: no ad-hoc z-index; Static vs pressable), with a decision-log row saying the selectors went and why.
This commit is contained in:
@@ -67,7 +67,6 @@ function TouchRow() {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{/* eslint-disable-next-line no-restricted-syntax -- a drawing of the segmented control, not a label */}
|
||||
<span className="inline-flex rounded-full border border-border bg-card p-0.5 text-xs">
|
||||
<span className={clsx(pill, "rounded-full bg-accent text-accent-fg")}>Mine</span>
|
||||
<span className={clsx(pill, "rounded-full text-muted")}>Library</span>
|
||||
|
||||
@@ -870,14 +870,6 @@
|
||||
"message": "px-frozen box size doesn't scale with --font-scale: give a grid column's minimum in rem (minmax(9.375rem,1fr)), not minmax(Npx,…).",
|
||||
"selector": "TemplateElement[value.raw=/minmax\\([\\d.]+px,/]"
|
||||
},
|
||||
{
|
||||
"message": "z-index off the layer scale: use a named level (z-under, z-base, z-menu, z-chrome, z-panel, z-rail, z-overlay, z-popover, z-tooltip), not z-N or z-[…].",
|
||||
"selector": "Literal[value=/(^|[\\s:])-?z-([1-9]\\d*|\\[[^\\]]+\\])(?![\\w-])/]"
|
||||
},
|
||||
{
|
||||
"message": "z-index off the layer scale: use a named level (z-under, z-base, z-menu, z-chrome, z-panel, z-rail, z-overlay, z-popover, z-tooltip), not z-N or z-[…].",
|
||||
"selector": "TemplateElement[value.raw=/(^|[\\s:])-?z-([1-9]\\d*|\\[[^\\]]+\\])(?![\\w-])/]"
|
||||
},
|
||||
{
|
||||
"message": "hover by a colour swap: use the B3 layer (`state-layer`, Pressable `layer`, `state-filled` on a fill), not hover:bg-card / bg-border / opacity-N.",
|
||||
"selector": "Literal[value=/(^|[\\s:])hover:(bg-(card|border|surface|muted)(?![\\w-])|bg-\\(--(hover|press)\\)|opacity-)/]"
|
||||
@@ -893,14 +885,6 @@
|
||||
{
|
||||
"message": "a palette colour: use a semantic token (text-rating, bg-live, bg-media-chrome, text-danger, …; DESIGN.md Tokens), not text-amber-500.",
|
||||
"selector": "TemplateElement[value.raw=/(^|[\\s:])(text|bg|border|fill|stroke|from|via|to|ring|outline|decoration|divide|caret|shadow)-(red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose|slate|gray|zinc|neutral|stone)-\\d/]"
|
||||
},
|
||||
{
|
||||
"message": "a static label with an edge reads as a pressable chip: use ui/Badge (flat, tonal) for a label that does nothing.",
|
||||
"selector": "JSXOpeningElement[name.name='span'] JSXAttribute[name.name='className'] Literal[value=/^(?=.*(^|\\s)rounded-(full|md|lg|xl|2xl)(\\s|$))(?=.*(^|\\s)border(\\s|$))/]"
|
||||
},
|
||||
{
|
||||
"message": "a static label with an edge reads as a pressable chip: use ui/Badge (flat, tonal) for a label that does nothing.",
|
||||
"selector": "JSXOpeningElement[name.name='span'] JSXAttribute[name.name='className'] TemplateElement[value.raw=/^(?=.*(^|\\s)rounded-(full|md|lg|xl|2xl)(\\s|$))(?=.*(^|\\s)border(\\s|$))/]"
|
||||
}
|
||||
],
|
||||
"no-self-assign": [2, { "props": true }],
|
||||
@@ -1520,8 +1504,7 @@
|
||||
"src/lib/useUrlMirror.dom.test.ts",
|
||||
"src/lib/verifyEntry.dom.test.tsx",
|
||||
"src/lib/viewportUnits.contract.test.ts",
|
||||
"src/lib/vocab.dom.test.ts",
|
||||
"src/lib/zLayer.contract.test.ts"
|
||||
"src/lib/vocab.dom.test.ts"
|
||||
],
|
||||
"lib/api/core.ts": ["src/lib/api/core.ts"],
|
||||
"lib/http.ts": ["src/lib/http.ts"],
|
||||
|
||||
@@ -13,7 +13,6 @@ async function messages(source: string, starts: string): Promise<number> {
|
||||
const swaps = (src: string) => messages(src, "hover by a colour swap");
|
||||
const glyphs = (src: string) => messages(src, "a glyph-only <a>");
|
||||
const palette = (src: string) => messages(src, "a palette colour");
|
||||
const edged = (src: string) => messages(src, "a static label with an edge");
|
||||
|
||||
describe("a hover by a colour swap", () => {
|
||||
// Assembled, so this file does not trip the very rule it probes.
|
||||
@@ -74,36 +73,3 @@ describe("a palette colour", () => {
|
||||
expect(await palette(`export const g = "bg-accent text-danger border-border";\n`)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
// F29: DESIGN.md "Static vs pressable": a label that does nothing is a flat Badge. A span drawn with a
|
||||
// rounded edge reads as a chip, gets clicked and does nothing (three sites and a private Badge had it).
|
||||
describe("a static label with an edge", () => {
|
||||
const b = "border"; // assembled, as above
|
||||
|
||||
it("is refused, in a plain class and inside clsx", async () => {
|
||||
const src = [
|
||||
'import clsx from "clsx";',
|
||||
"export const A = ({ on }: { on: boolean }) => (",
|
||||
" <>",
|
||||
` <span className="px-2 rounded-full ${b} ${b}-accent/40 text-accent">x</span>`,
|
||||
` <span className={clsx("rounded-lg ${b} ${b}-dashed", on && "text-accent")}>y</span>`,
|
||||
" </>",
|
||||
");",
|
||||
].join("\n");
|
||||
expect(await edged(src)).toBe(2);
|
||||
});
|
||||
|
||||
it("passes a flat tint, an edge on a non-label element, a span with no rounding, a drawn check mark", async () => {
|
||||
const src = [
|
||||
"export const B = () => (",
|
||||
" <>",
|
||||
' <span className="rounded-full bg-fg/8 text-muted">x</span>',
|
||||
` <div className="rounded-lg ${b} ${b}-border">y</div>`,
|
||||
` <span className="${b}-b ${b}-border">z</span>`,
|
||||
` <span className="grid h-3.5 w-3.5 rounded ${b}">✓</span>`,
|
||||
" </>",
|
||||
");",
|
||||
].join("\n");
|
||||
expect(await edged(src)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { eslint } from "./lintProbe.testkit";
|
||||
|
||||
// The layer-scale rule in eslint.config.js (DESIGN.md Tokens: "No ad-hoc z-index"). A numeric `z-10`
|
||||
// happened to equal `base` and passed every review; a `no-restricted-syntax` selector that matches
|
||||
// nothing looks exactly like a clean codebase, so pin that it fires.
|
||||
|
||||
async function refused(source: string): Promise<number> {
|
||||
const [result] = await eslint.lintText(source, { filePath: "src/components/__probe.tsx" });
|
||||
return (result?.messages ?? []).filter((m) => m.message.startsWith("z-index off the layer scale"))
|
||||
.length;
|
||||
}
|
||||
|
||||
describe("a z-index off the layer scale", () => {
|
||||
// Assembled, so this file does not trip the very rule it probes.
|
||||
const z = (v: string) => `z-${v}`;
|
||||
|
||||
it("is refused as a number, an arbitrary value or a variant, in a string and a template", async () => {
|
||||
expect(await refused(`export const a = "absolute ${z("10")} top-0";\n`)).toBe(1);
|
||||
expect(await refused(`export const b = "hover:${z("[5]")}";\n`)).toBe(1);
|
||||
expect(await refused("export const c = `x ${1} -" + z("20") + "`;\n")).toBe(1);
|
||||
});
|
||||
|
||||
it("leaves a named level, z-0 and z-auto alone", async () => {
|
||||
expect(await refused(`export const d = "${z("base")} ${z("menu")} ${z("tooltip")}";\n`)).toBe(
|
||||
0,
|
||||
);
|
||||
expect(await refused(`export const e = "${z("0")} md:${z("auto")}";\n`)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
// The Plex player's notices (the track-switch OSD, the subtitle notice) sat on `menu` while its settings
|
||||
// and tracks popovers had no level: a notice drew over the open menu (E28 audit, seen live). A menu is
|
||||
// above a notice; the info overlay (`menu`, later in the tree) still covers both.
|
||||
describe("the Plex player's layers", () => {
|
||||
const src = ["PlexPlayer.tsx", "PlexPlayerSettings.tsx"]
|
||||
.map((f) => readFileSync(new URL(`../components/${f}`, import.meta.url), "utf8"))
|
||||
.join("\n");
|
||||
const classes = (marker: RegExp) =>
|
||||
[...src.matchAll(/className="([^"]*)"/g)].map((m) => m[1]!).filter((c) => marker.test(c));
|
||||
|
||||
it("puts every popover on the menu level", () => {
|
||||
const popovers = classes(
|
||||
/\bbottom-full\b.*\bbg-media-chrome\b|\bbg-media-chrome\b.*\bbottom-full\b/,
|
||||
);
|
||||
expect(popovers).toHaveLength(1); // the settings panel, which renders inside the player
|
||||
for (const c of popovers) expect(c).toMatch(/\bz-menu\b/);
|
||||
// The tracks list and the ⋯ menu are on the popover engine (E28 review D3), which lifts them to
|
||||
// z-popover — above the player's own z-overlay — and into the fullscreen element.
|
||||
expect([
|
||||
...src.matchAll(/<PopoverSurface\b[^>]*?className=\{`\$\{PLAYER_MENU\}/g),
|
||||
]).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("keeps the notices a level below", () => {
|
||||
const notices = classes(/pointer-events-none absolute inset-x-0 bottom-(24|36)\b/);
|
||||
expect(notices).toHaveLength(2);
|
||||
for (const c of notices) expect(c).toMatch(/\bz-base\b/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user