chore(frontend): tighten eslint/axe gates, remove reader waivers (B5 done, spec ② complete)
CI / backend (push) Canceled after 0s
CI / frontend (push) Canceled after 0s

This commit is contained in:
2026-09-16 19:27:25 +08:00
parent 395be9688d
commit ef57b194f4
12 changed files with 99 additions and 59 deletions
+12
View File
@@ -31,6 +31,18 @@ export async function adminApi(): Promise<APIRequestContext> {
return request.newContext({ baseURL: BASE, extraHTTPHeaders: { Authorization: `Bearer ${token}` } });
}
/** adminApi 登录带 429 退避重试:三 spec 并发 worker 的登录总数可能顶到后端 1min/5 次限流门,等窗口即可;仅消耗等待预算,不改用例语义 */
export async function adminApiRetry(): Promise<APIRequestContext> {
for (let i = 0; ; i++) {
try {
return await adminApi();
} catch (e) {
if (i > 20 || !(e instanceof Error) || !e.message.includes("HTTP 429")) throw e;
await new Promise((r) => setTimeout(r, 3000));
}
}
}
export async function ensureLibrary(ctx: APIRequestContext, name: string): Promise<number> {
const libs = (await (await ctx.get("/api/libraries")).json()) as { id: number; name: string }[];
const hit = libs.find((l) => l.name === name);
+3 -11
View File
@@ -8,18 +8,10 @@ interface Waiver {
}
/**
* critical/serious 违规的逐条豁免清单(spec S3):
* 仅允许「属于将被 ② 阅读器改版重写的旧 chrome」的问题进这里,reason 必须写明归属。
* 例:{ page: "reader-chrome", rule: "color-contrast", reason: "旧 rd-* chrome 配色,② 迁移 shadcn token 后移除本豁免" }
* critical/serious 违规的逐条豁免清单(④ 基建):
* ② 阅读器改版后旧 chrome 重写完毕,本期清空;新增豁免必须写明 reason 并控制在一次性条件。
*/
const WAIVERS: Waiver[] = [
{
page: "reader-chrome",
rule: "color-contrast",
reason:
"旧 chrome:Reader.tsx 头栏(书架返回钮/书名/库名/进度)用 stone-* 配色,对比不足;② 阅读器改版迁移 shadcn token 后移除本豁免",
},
];
const WAIVERS: Waiver[] = [];
export async function scanA11y(page: Page, name: string): Promise<void> {
// 等 CSS 动画/过渡收尾(如 fx-rise 入场淡入)再扫:动画途中采样会因不透明度混色造成 contrast 误报;2s 上限兜底长动画