ultra11y 5.57.4 → 5.57.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.opencode/plugins/ultra11y.js +1 -1
- package/package.json +1 -1
- package/scripts/ultra11y.mjs +111 -5
- package/skills/review-a11y/SKILL.md +1 -1
- package/skills/review-a11y/scripts/ultra11y.mjs +111 -5
- package/skills/ultra11y/SKILL.md +1 -1
- package/skills/ultra11y/scripts/ultra11y.mjs +111 -5
- package/skills/ultra11y/templates/gitlab-ci.yml +1 -1
- package/src/adjudicate-subjects.ts +4 -1
- package/src/graph/imports.ts +82 -1
- package/src/rules/cross-registry.ts +9 -2
- package/src/rules/headings.ts +12 -0
- package/src/rules/rule.ts +38 -1
- package/src/types.ts +1 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "ultra11y",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "RGAA 4.1.2 accessibility audits on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports in Claude Code.",
|
|
13
|
-
"version": "5.57.
|
|
13
|
+
"version": "5.57.5",
|
|
14
14
|
"author": { "name": "maxgfr" },
|
|
15
15
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
16
16
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
3
|
"description": "RGAA 4.1.2 accessibility audits, the French State's standard, on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports. Never declares conforming what it has not verified.",
|
|
4
|
-
"version": "5.57.
|
|
4
|
+
"version": "5.57.5",
|
|
5
5
|
"author": { "name": "maxgfr" },
|
|
6
6
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
7
7
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
3
|
"description": "RGAA 4.1.2 accessibility audits, the French State's standard, on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports. Never declares conforming what it has not verified.",
|
|
4
|
-
"version": "5.57.
|
|
4
|
+
"version": "5.57.5",
|
|
5
5
|
"author": { "name": "maxgfr", "url": "https://github.com/maxgfr" },
|
|
6
6
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
7
7
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -44,7 +44,7 @@ import { fileURLToPath } from "node:url";
|
|
|
44
44
|
// does not carry it, so a user's own ultra11y.js is never clobbered. Kept as text, not as
|
|
45
45
|
// an export (see above).
|
|
46
46
|
const ULTRA11Y_OPENCODE_PLUGIN = "ULTRA11Y_OPENCODE_PLUGIN";
|
|
47
|
-
const ULTRA11Y_PLUGIN_VERSION = "5.57.
|
|
47
|
+
const ULTRA11Y_PLUGIN_VERSION = "5.57.5";
|
|
48
48
|
const PLUGIN_ID = "ultra11y";
|
|
49
49
|
const SKILL_NAMES = ["ultra11y", "review-a11y"];
|
|
50
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
|
-
"version": "5.57.
|
|
3
|
+
"version": "5.57.5",
|
|
4
4
|
"description": "Audit d'accessibilité RGAA 4.1.2, le référentiel de l'État : rapport daté, grille des 106 critères, backlog et tickets. Moteur statique, navigateur et jugement IA contre-vérifié. Il ne déclare jamais conforme ce qu'il n'a pas vérifié. Socle WCAG 2.2 AA.",
|
|
5
5
|
"homepage": "https://socialgouv.github.io/ultra11y/",
|
|
6
6
|
"type": "module",
|
package/scripts/ultra11y.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { join as join56, relative as relative7, resolve as resolve19, sep as sep
|
|
|
6
6
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL3 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/types.ts
|
|
9
|
-
var VERSION = "5.57.
|
|
9
|
+
var VERSION = "5.57.5";
|
|
10
10
|
var SCHEMA_VERSION = 2;
|
|
11
11
|
function isAdjudicated(by) {
|
|
12
12
|
return by === "agent" || by === "human";
|
|
@@ -40359,6 +40359,32 @@ function toFinding(doc, ruleId, def, rf, ruleAdvisory) {
|
|
|
40359
40359
|
...rf.advisory ?? ruleAdvisory ? { advisory: true } : {}
|
|
40360
40360
|
};
|
|
40361
40361
|
}
|
|
40362
|
+
var LINK_MODULE = /^(?:next\/link|react-router(?:-dom)?|@remix-run\/react|gatsby|@tanstack\/[\w-]*router)$/;
|
|
40363
|
+
var LINK_EXPORTS = /* @__PURE__ */ new Set(["Link", "NavLink"]);
|
|
40364
|
+
var linkCache = /* @__PURE__ */ new WeakMap();
|
|
40365
|
+
function routerLinkLocals(doc) {
|
|
40366
|
+
const hit = linkCache.get(doc);
|
|
40367
|
+
if (hit) return hit;
|
|
40368
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
40369
|
+
for (const m of doc.source.matchAll(/(?:^|[\n;])\s*import\s+(?!type\b)([^;'"]*?)\s+from\s+["']([^"']+)["']/g)) {
|
|
40370
|
+
const clause = m[1] ?? "";
|
|
40371
|
+
const mod = m[2] ?? "";
|
|
40372
|
+
if (!LINK_MODULE.test(mod)) continue;
|
|
40373
|
+
const def = /^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(clause)?.[1];
|
|
40374
|
+
if (def && mod === "next/link") out2.add(def);
|
|
40375
|
+
for (const spec of (/\{([^}]*)\}/.exec(clause)?.[1] ?? "").split(",")) {
|
|
40376
|
+
const [imported, local] = spec.replace(/^\s*type\s+/, "").trim().split(/\s+as\s+/);
|
|
40377
|
+
if (imported && LINK_EXPORTS.has(imported.trim())) out2.add((local ?? imported).trim());
|
|
40378
|
+
}
|
|
40379
|
+
}
|
|
40380
|
+
linkCache.set(doc, out2);
|
|
40381
|
+
return out2;
|
|
40382
|
+
}
|
|
40383
|
+
function rendersNativeLink(doc, el) {
|
|
40384
|
+
const dest = (name2) => (boundAttr(el, name2) ?? "").trim() !== "";
|
|
40385
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy") return false;
|
|
40386
|
+
return routerLinkLocals(doc).has(el.tag) && (dest("href") || dest("to"));
|
|
40387
|
+
}
|
|
40362
40388
|
|
|
40363
40389
|
// src/rules/rendered.ts
|
|
40364
40390
|
import { readFileSync as readFileSync15 } from "fs";
|
|
@@ -49619,7 +49645,8 @@ var SUBJECTS = {
|
|
|
49619
49645
|
// Pointer, touch, gesture and drag handlers — everything a keyboard may not reach.
|
|
49620
49646
|
pointerHandlers: (docs) => docs.flatMap((d) => [
|
|
49621
49647
|
...d.elements.filter(
|
|
49622
|
-
(e) => !INTERACTIVE_TAGS.includes(e.tag) &&
|
|
49648
|
+
(e) => !INTERACTIVE_TAGS.includes(e.tag) && !rendersNativeLink(d, e) && // Next's <Link href> IS an <a href> (#133)
|
|
49649
|
+
Object.keys(e.attribs).some((k) => /^on(click|mousedown|mouseup|mouseenter|pointerdown|touchstart)$/i.test(k))
|
|
49623
49650
|
).map((e) => h(d, e, `<${e.tag}> carries a pointer handler but is not natively interactive \u2014 keyboard equivalent?`, `clickable|${e.tag}|${t(e, 40)}`)),
|
|
49624
49651
|
...linesOf(d, /\bon(?:MouseDown|PointerDown|TouchStart)\s*=/).map(
|
|
49625
49652
|
(l) => hAt(d, l.line, "handler", `down-event handler (action must not fire on DOWN, or must be abortable): ${l.text}`, `downevent|${l.text}`)
|
|
@@ -52440,6 +52467,12 @@ var emptyHeading = {
|
|
|
52440
52467
|
}
|
|
52441
52468
|
};
|
|
52442
52469
|
var DL_ALLOWED = /* @__PURE__ */ new Set(["dt", "dd", "div", "script", "template", "slot", "#fragment"]);
|
|
52470
|
+
function groupParentUnknown(doc, el) {
|
|
52471
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy" && doc.kind !== "sfc") return false;
|
|
52472
|
+
let p = el.parent;
|
|
52473
|
+
while (p && (p.tag === "div" || p.tag === "#fragment")) p = p.parent;
|
|
52474
|
+
return p === null || doc.kind === "sfc" && p.tag === "template" && p.parent === null;
|
|
52475
|
+
}
|
|
52443
52476
|
var dlStructure = {
|
|
52444
52477
|
id: "dl-structure",
|
|
52445
52478
|
criteria: ["1.3.1"],
|
|
@@ -52459,6 +52492,7 @@ var dlStructure = {
|
|
|
52459
52492
|
if (el.tag !== "dt" && el.tag !== "dd") continue;
|
|
52460
52493
|
const chain = ancestors(el);
|
|
52461
52494
|
if (chain.some((a) => a.tag === "dl" || !isIntrinsic(a.tag))) continue;
|
|
52495
|
+
if (groupParentUnknown(doc, el)) continue;
|
|
52462
52496
|
out2.push({ criteriaId: "1.3.1", el, msgId: "dl-structure.orphan", params: { tag: el.tag } });
|
|
52463
52497
|
}
|
|
52464
52498
|
return out2;
|
|
@@ -54723,10 +54757,14 @@ var crossPropDrilledNameLost = {
|
|
|
54723
54757
|
const findings = [];
|
|
54724
54758
|
for (const el of doc.elements) {
|
|
54725
54759
|
if (!isComponentUsage(el)) continue;
|
|
54726
|
-
const
|
|
54727
|
-
if (!
|
|
54760
|
+
const given = NAME_PROPS_PASSED.filter((p) => (attr(el, p) ?? "").trim() !== "");
|
|
54761
|
+
if (!given.length) continue;
|
|
54728
54762
|
const def = resolveUsage(graph, doc.file, el.tag);
|
|
54729
54763
|
if (!def?.hasControl || def.acceptsName || def.controlHasName) continue;
|
|
54764
|
+
const reads = def.readsProps;
|
|
54765
|
+
if (!reads) continue;
|
|
54766
|
+
const passed = given.find((p) => !reads.includes(p));
|
|
54767
|
+
if (!passed) continue;
|
|
54730
54768
|
findings.push({
|
|
54731
54769
|
criteriaId: "4.1.2",
|
|
54732
54770
|
el,
|
|
@@ -55009,6 +55047,62 @@ function findControl(fnNode) {
|
|
|
55009
55047
|
function posOf(node) {
|
|
55010
55048
|
return { line: node.loc?.start.line ?? 1, col: (node.loc?.start.column ?? 0) + 1 };
|
|
55011
55049
|
}
|
|
55050
|
+
function referencedNames(body3) {
|
|
55051
|
+
const skip = /* @__PURE__ */ new Set();
|
|
55052
|
+
const out2 = [];
|
|
55053
|
+
walkAst(body3, (n) => {
|
|
55054
|
+
if ((n.type === "MemberExpression" || n.type === "OptionalMemberExpression") && !n.computed) {
|
|
55055
|
+
const prop = asNode(n.property);
|
|
55056
|
+
if (prop) skip.add(prop);
|
|
55057
|
+
} else if ((n.type === "ObjectProperty" || n.type === "ObjectMethod") && !n.computed && !n.shorthand) {
|
|
55058
|
+
const key2 = asNode(n.key);
|
|
55059
|
+
if (key2) skip.add(key2);
|
|
55060
|
+
} else if (n.type === "Identifier" && !skip.has(n)) out2.push(n);
|
|
55061
|
+
});
|
|
55062
|
+
return out2;
|
|
55063
|
+
}
|
|
55064
|
+
function identName(n) {
|
|
55065
|
+
return n?.type === "Identifier" && typeof n.name === "string" ? n.name : "";
|
|
55066
|
+
}
|
|
55067
|
+
function readsProps(fnNode) {
|
|
55068
|
+
let param = asNodes(fnNode.params)[0];
|
|
55069
|
+
if (!param) return [];
|
|
55070
|
+
if (param.type === "AssignmentPattern") param = asNode(param.left);
|
|
55071
|
+
const refs = referencedNames(fnNode.body);
|
|
55072
|
+
if (param?.type === "ObjectPattern") {
|
|
55073
|
+
const used2 = [];
|
|
55074
|
+
for (const prop of asNodes(param.properties)) {
|
|
55075
|
+
if (prop.type === "RestElement") {
|
|
55076
|
+
const rest = identName(asNode(prop.argument));
|
|
55077
|
+
if (!rest || refs.some((r) => r.name === rest)) return null;
|
|
55078
|
+
continue;
|
|
55079
|
+
}
|
|
55080
|
+
const key2 = asNode(prop.key);
|
|
55081
|
+
const keyName = identName(key2) || (key2?.type === "StringLiteral" && typeof key2.value === "string" ? key2.value : "");
|
|
55082
|
+
if (prop.type !== "ObjectProperty" || prop.computed || !keyName) return null;
|
|
55083
|
+
let value = asNode(prop.value);
|
|
55084
|
+
if (value?.type === "AssignmentPattern") value = asNode(value.left);
|
|
55085
|
+
const local = identName(value);
|
|
55086
|
+
if (!local) return null;
|
|
55087
|
+
if (refs.some((r) => r.name === local)) used2.push(keyName);
|
|
55088
|
+
}
|
|
55089
|
+
return used2;
|
|
55090
|
+
}
|
|
55091
|
+
const whole = identName(param);
|
|
55092
|
+
if (!whole) return null;
|
|
55093
|
+
const used = [];
|
|
55094
|
+
const members = /* @__PURE__ */ new Set();
|
|
55095
|
+
walkAst(fnNode.body, (n) => {
|
|
55096
|
+
if (n.type !== "MemberExpression" && n.type !== "OptionalMemberExpression" || n.computed) return;
|
|
55097
|
+
const obj2 = asNode(n.object);
|
|
55098
|
+
const prop = identName(asNode(n.property));
|
|
55099
|
+
if (obj2 && identName(obj2) === whole && prop) {
|
|
55100
|
+
members.add(obj2);
|
|
55101
|
+
used.push(prop);
|
|
55102
|
+
}
|
|
55103
|
+
});
|
|
55104
|
+
return refs.some((r) => r.name === whole && !members.has(r)) ? null : used;
|
|
55105
|
+
}
|
|
55012
55106
|
function analyzeComponent(name2, file, fnNode) {
|
|
55013
55107
|
const control = findControl(fnNode);
|
|
55014
55108
|
if (!control) {
|
|
@@ -55035,7 +55129,19 @@ function analyzeComponent(name2, file, fnNode) {
|
|
|
55035
55129
|
const acceptsName = spreadsProps || forwardsAria || acceptsNameViaChildren;
|
|
55036
55130
|
const controlHasName = literalAriaName || forwardsAria || hasLiteralText(control);
|
|
55037
55131
|
const rendersIconOnlyControl = hasIconChild2(control) && !hasLiteralText(control) && !literalAriaName && !forwardsAria;
|
|
55038
|
-
return {
|
|
55132
|
+
return {
|
|
55133
|
+
name: name2,
|
|
55134
|
+
file,
|
|
55135
|
+
line,
|
|
55136
|
+
col,
|
|
55137
|
+
hasControl: true,
|
|
55138
|
+
rendersIconOnlyControl,
|
|
55139
|
+
acceptsName,
|
|
55140
|
+
controlHasName,
|
|
55141
|
+
spreadsProps,
|
|
55142
|
+
forwardsAria,
|
|
55143
|
+
readsProps: readsProps(fnNode)
|
|
55144
|
+
};
|
|
55039
55145
|
}
|
|
55040
55146
|
function pascalCaseBasename(posix3) {
|
|
55041
55147
|
const base = (posix3.split("/").pop() ?? posix3).replace(/\.[^.]+$/, "");
|
|
@@ -3,7 +3,7 @@ name: review-a11y
|
|
|
3
3
|
description: "Use to REVIEW changed frontend code for accessibility: staged files, a working diff, branch, or PR; prompts such as 'review a11y', 'is this accessible?', or 'anything to fix before merge?'; and hook or CI findings on a change. Run the bundled install-free engine with cross-file JSX/TSX analysis, then adjudicate candidates and return a severity-ranked WCAG 2.2 AA review with file:line fixes, residual rendering risks, and a verdict. Use `ultra11y` instead for whole-repo audits, dated conformance reports, country standards, PRD backlogs, or authoring accessible markup."
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
|
-
version: 5.57.
|
|
6
|
+
version: 5.57.5
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# review-a11y — accessibility review of changed code
|
|
@@ -6,7 +6,7 @@ import { join as join56, relative as relative7, resolve as resolve19, sep as sep
|
|
|
6
6
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL3 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/types.ts
|
|
9
|
-
var VERSION = "5.57.
|
|
9
|
+
var VERSION = "5.57.5";
|
|
10
10
|
var SCHEMA_VERSION = 2;
|
|
11
11
|
function isAdjudicated(by) {
|
|
12
12
|
return by === "agent" || by === "human";
|
|
@@ -40359,6 +40359,32 @@ function toFinding(doc, ruleId, def, rf, ruleAdvisory) {
|
|
|
40359
40359
|
...rf.advisory ?? ruleAdvisory ? { advisory: true } : {}
|
|
40360
40360
|
};
|
|
40361
40361
|
}
|
|
40362
|
+
var LINK_MODULE = /^(?:next\/link|react-router(?:-dom)?|@remix-run\/react|gatsby|@tanstack\/[\w-]*router)$/;
|
|
40363
|
+
var LINK_EXPORTS = /* @__PURE__ */ new Set(["Link", "NavLink"]);
|
|
40364
|
+
var linkCache = /* @__PURE__ */ new WeakMap();
|
|
40365
|
+
function routerLinkLocals(doc) {
|
|
40366
|
+
const hit = linkCache.get(doc);
|
|
40367
|
+
if (hit) return hit;
|
|
40368
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
40369
|
+
for (const m of doc.source.matchAll(/(?:^|[\n;])\s*import\s+(?!type\b)([^;'"]*?)\s+from\s+["']([^"']+)["']/g)) {
|
|
40370
|
+
const clause = m[1] ?? "";
|
|
40371
|
+
const mod = m[2] ?? "";
|
|
40372
|
+
if (!LINK_MODULE.test(mod)) continue;
|
|
40373
|
+
const def = /^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(clause)?.[1];
|
|
40374
|
+
if (def && mod === "next/link") out2.add(def);
|
|
40375
|
+
for (const spec of (/\{([^}]*)\}/.exec(clause)?.[1] ?? "").split(",")) {
|
|
40376
|
+
const [imported, local] = spec.replace(/^\s*type\s+/, "").trim().split(/\s+as\s+/);
|
|
40377
|
+
if (imported && LINK_EXPORTS.has(imported.trim())) out2.add((local ?? imported).trim());
|
|
40378
|
+
}
|
|
40379
|
+
}
|
|
40380
|
+
linkCache.set(doc, out2);
|
|
40381
|
+
return out2;
|
|
40382
|
+
}
|
|
40383
|
+
function rendersNativeLink(doc, el) {
|
|
40384
|
+
const dest = (name2) => (boundAttr(el, name2) ?? "").trim() !== "";
|
|
40385
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy") return false;
|
|
40386
|
+
return routerLinkLocals(doc).has(el.tag) && (dest("href") || dest("to"));
|
|
40387
|
+
}
|
|
40362
40388
|
|
|
40363
40389
|
// src/rules/rendered.ts
|
|
40364
40390
|
import { readFileSync as readFileSync15 } from "fs";
|
|
@@ -49619,7 +49645,8 @@ var SUBJECTS = {
|
|
|
49619
49645
|
// Pointer, touch, gesture and drag handlers — everything a keyboard may not reach.
|
|
49620
49646
|
pointerHandlers: (docs) => docs.flatMap((d) => [
|
|
49621
49647
|
...d.elements.filter(
|
|
49622
|
-
(e) => !INTERACTIVE_TAGS.includes(e.tag) &&
|
|
49648
|
+
(e) => !INTERACTIVE_TAGS.includes(e.tag) && !rendersNativeLink(d, e) && // Next's <Link href> IS an <a href> (#133)
|
|
49649
|
+
Object.keys(e.attribs).some((k) => /^on(click|mousedown|mouseup|mouseenter|pointerdown|touchstart)$/i.test(k))
|
|
49623
49650
|
).map((e) => h(d, e, `<${e.tag}> carries a pointer handler but is not natively interactive \u2014 keyboard equivalent?`, `clickable|${e.tag}|${t(e, 40)}`)),
|
|
49624
49651
|
...linesOf(d, /\bon(?:MouseDown|PointerDown|TouchStart)\s*=/).map(
|
|
49625
49652
|
(l) => hAt(d, l.line, "handler", `down-event handler (action must not fire on DOWN, or must be abortable): ${l.text}`, `downevent|${l.text}`)
|
|
@@ -52440,6 +52467,12 @@ var emptyHeading = {
|
|
|
52440
52467
|
}
|
|
52441
52468
|
};
|
|
52442
52469
|
var DL_ALLOWED = /* @__PURE__ */ new Set(["dt", "dd", "div", "script", "template", "slot", "#fragment"]);
|
|
52470
|
+
function groupParentUnknown(doc, el) {
|
|
52471
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy" && doc.kind !== "sfc") return false;
|
|
52472
|
+
let p = el.parent;
|
|
52473
|
+
while (p && (p.tag === "div" || p.tag === "#fragment")) p = p.parent;
|
|
52474
|
+
return p === null || doc.kind === "sfc" && p.tag === "template" && p.parent === null;
|
|
52475
|
+
}
|
|
52443
52476
|
var dlStructure = {
|
|
52444
52477
|
id: "dl-structure",
|
|
52445
52478
|
criteria: ["1.3.1"],
|
|
@@ -52459,6 +52492,7 @@ var dlStructure = {
|
|
|
52459
52492
|
if (el.tag !== "dt" && el.tag !== "dd") continue;
|
|
52460
52493
|
const chain = ancestors(el);
|
|
52461
52494
|
if (chain.some((a) => a.tag === "dl" || !isIntrinsic(a.tag))) continue;
|
|
52495
|
+
if (groupParentUnknown(doc, el)) continue;
|
|
52462
52496
|
out2.push({ criteriaId: "1.3.1", el, msgId: "dl-structure.orphan", params: { tag: el.tag } });
|
|
52463
52497
|
}
|
|
52464
52498
|
return out2;
|
|
@@ -54723,10 +54757,14 @@ var crossPropDrilledNameLost = {
|
|
|
54723
54757
|
const findings = [];
|
|
54724
54758
|
for (const el of doc.elements) {
|
|
54725
54759
|
if (!isComponentUsage(el)) continue;
|
|
54726
|
-
const
|
|
54727
|
-
if (!
|
|
54760
|
+
const given = NAME_PROPS_PASSED.filter((p) => (attr(el, p) ?? "").trim() !== "");
|
|
54761
|
+
if (!given.length) continue;
|
|
54728
54762
|
const def = resolveUsage(graph, doc.file, el.tag);
|
|
54729
54763
|
if (!def?.hasControl || def.acceptsName || def.controlHasName) continue;
|
|
54764
|
+
const reads = def.readsProps;
|
|
54765
|
+
if (!reads) continue;
|
|
54766
|
+
const passed = given.find((p) => !reads.includes(p));
|
|
54767
|
+
if (!passed) continue;
|
|
54730
54768
|
findings.push({
|
|
54731
54769
|
criteriaId: "4.1.2",
|
|
54732
54770
|
el,
|
|
@@ -55009,6 +55047,62 @@ function findControl(fnNode) {
|
|
|
55009
55047
|
function posOf(node) {
|
|
55010
55048
|
return { line: node.loc?.start.line ?? 1, col: (node.loc?.start.column ?? 0) + 1 };
|
|
55011
55049
|
}
|
|
55050
|
+
function referencedNames(body3) {
|
|
55051
|
+
const skip = /* @__PURE__ */ new Set();
|
|
55052
|
+
const out2 = [];
|
|
55053
|
+
walkAst(body3, (n) => {
|
|
55054
|
+
if ((n.type === "MemberExpression" || n.type === "OptionalMemberExpression") && !n.computed) {
|
|
55055
|
+
const prop = asNode(n.property);
|
|
55056
|
+
if (prop) skip.add(prop);
|
|
55057
|
+
} else if ((n.type === "ObjectProperty" || n.type === "ObjectMethod") && !n.computed && !n.shorthand) {
|
|
55058
|
+
const key2 = asNode(n.key);
|
|
55059
|
+
if (key2) skip.add(key2);
|
|
55060
|
+
} else if (n.type === "Identifier" && !skip.has(n)) out2.push(n);
|
|
55061
|
+
});
|
|
55062
|
+
return out2;
|
|
55063
|
+
}
|
|
55064
|
+
function identName(n) {
|
|
55065
|
+
return n?.type === "Identifier" && typeof n.name === "string" ? n.name : "";
|
|
55066
|
+
}
|
|
55067
|
+
function readsProps(fnNode) {
|
|
55068
|
+
let param = asNodes(fnNode.params)[0];
|
|
55069
|
+
if (!param) return [];
|
|
55070
|
+
if (param.type === "AssignmentPattern") param = asNode(param.left);
|
|
55071
|
+
const refs = referencedNames(fnNode.body);
|
|
55072
|
+
if (param?.type === "ObjectPattern") {
|
|
55073
|
+
const used2 = [];
|
|
55074
|
+
for (const prop of asNodes(param.properties)) {
|
|
55075
|
+
if (prop.type === "RestElement") {
|
|
55076
|
+
const rest = identName(asNode(prop.argument));
|
|
55077
|
+
if (!rest || refs.some((r) => r.name === rest)) return null;
|
|
55078
|
+
continue;
|
|
55079
|
+
}
|
|
55080
|
+
const key2 = asNode(prop.key);
|
|
55081
|
+
const keyName = identName(key2) || (key2?.type === "StringLiteral" && typeof key2.value === "string" ? key2.value : "");
|
|
55082
|
+
if (prop.type !== "ObjectProperty" || prop.computed || !keyName) return null;
|
|
55083
|
+
let value = asNode(prop.value);
|
|
55084
|
+
if (value?.type === "AssignmentPattern") value = asNode(value.left);
|
|
55085
|
+
const local = identName(value);
|
|
55086
|
+
if (!local) return null;
|
|
55087
|
+
if (refs.some((r) => r.name === local)) used2.push(keyName);
|
|
55088
|
+
}
|
|
55089
|
+
return used2;
|
|
55090
|
+
}
|
|
55091
|
+
const whole = identName(param);
|
|
55092
|
+
if (!whole) return null;
|
|
55093
|
+
const used = [];
|
|
55094
|
+
const members = /* @__PURE__ */ new Set();
|
|
55095
|
+
walkAst(fnNode.body, (n) => {
|
|
55096
|
+
if (n.type !== "MemberExpression" && n.type !== "OptionalMemberExpression" || n.computed) return;
|
|
55097
|
+
const obj2 = asNode(n.object);
|
|
55098
|
+
const prop = identName(asNode(n.property));
|
|
55099
|
+
if (obj2 && identName(obj2) === whole && prop) {
|
|
55100
|
+
members.add(obj2);
|
|
55101
|
+
used.push(prop);
|
|
55102
|
+
}
|
|
55103
|
+
});
|
|
55104
|
+
return refs.some((r) => r.name === whole && !members.has(r)) ? null : used;
|
|
55105
|
+
}
|
|
55012
55106
|
function analyzeComponent(name2, file, fnNode) {
|
|
55013
55107
|
const control = findControl(fnNode);
|
|
55014
55108
|
if (!control) {
|
|
@@ -55035,7 +55129,19 @@ function analyzeComponent(name2, file, fnNode) {
|
|
|
55035
55129
|
const acceptsName = spreadsProps || forwardsAria || acceptsNameViaChildren;
|
|
55036
55130
|
const controlHasName = literalAriaName || forwardsAria || hasLiteralText(control);
|
|
55037
55131
|
const rendersIconOnlyControl = hasIconChild2(control) && !hasLiteralText(control) && !literalAriaName && !forwardsAria;
|
|
55038
|
-
return {
|
|
55132
|
+
return {
|
|
55133
|
+
name: name2,
|
|
55134
|
+
file,
|
|
55135
|
+
line,
|
|
55136
|
+
col,
|
|
55137
|
+
hasControl: true,
|
|
55138
|
+
rendersIconOnlyControl,
|
|
55139
|
+
acceptsName,
|
|
55140
|
+
controlHasName,
|
|
55141
|
+
spreadsProps,
|
|
55142
|
+
forwardsAria,
|
|
55143
|
+
readsProps: readsProps(fnNode)
|
|
55144
|
+
};
|
|
55039
55145
|
}
|
|
55040
55146
|
function pascalCaseBasename(posix3) {
|
|
55041
55147
|
const base = (posix3.split("/").pop() ?? posix3).replace(/\.[^.]+$/, "");
|
package/skills/ultra11y/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: ultra11y
|
|
|
3
3
|
description: "Use to AUDIT a site, repository, or page against RGAA 4.1.2, the French State's accessibility standard (référentiel de l'État), on a WCAG 2.2 AA core (other country standards as packs); produce a dated conformance report, criterion grid, PRD backlog, or tickets; AUTHOR accessible markup; fix accessibility; or wire a repo gate and rendered-DOM capture pipeline. The bundled install-free engine runs 102 static checks tied to success criteria, while the agent adjudicates judgment criteria and routes rendering criteria to browser scans; check/verify reject invented non-conformities and never declare conforming what was not verified. Use `review-a11y` instead for a review scoped only to a diff, branch, or PR."
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
|
-
version: 5.57.
|
|
6
|
+
version: 5.57.5
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# ultra11y — audit WCAG 2.2 AA and write accessible markup
|
|
@@ -6,7 +6,7 @@ import { join as join56, relative as relative7, resolve as resolve19, sep as sep
|
|
|
6
6
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL3 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/types.ts
|
|
9
|
-
var VERSION = "5.57.
|
|
9
|
+
var VERSION = "5.57.5";
|
|
10
10
|
var SCHEMA_VERSION = 2;
|
|
11
11
|
function isAdjudicated(by) {
|
|
12
12
|
return by === "agent" || by === "human";
|
|
@@ -40359,6 +40359,32 @@ function toFinding(doc, ruleId, def, rf, ruleAdvisory) {
|
|
|
40359
40359
|
...rf.advisory ?? ruleAdvisory ? { advisory: true } : {}
|
|
40360
40360
|
};
|
|
40361
40361
|
}
|
|
40362
|
+
var LINK_MODULE = /^(?:next\/link|react-router(?:-dom)?|@remix-run\/react|gatsby|@tanstack\/[\w-]*router)$/;
|
|
40363
|
+
var LINK_EXPORTS = /* @__PURE__ */ new Set(["Link", "NavLink"]);
|
|
40364
|
+
var linkCache = /* @__PURE__ */ new WeakMap();
|
|
40365
|
+
function routerLinkLocals(doc) {
|
|
40366
|
+
const hit = linkCache.get(doc);
|
|
40367
|
+
if (hit) return hit;
|
|
40368
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
40369
|
+
for (const m of doc.source.matchAll(/(?:^|[\n;])\s*import\s+(?!type\b)([^;'"]*?)\s+from\s+["']([^"']+)["']/g)) {
|
|
40370
|
+
const clause = m[1] ?? "";
|
|
40371
|
+
const mod = m[2] ?? "";
|
|
40372
|
+
if (!LINK_MODULE.test(mod)) continue;
|
|
40373
|
+
const def = /^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(clause)?.[1];
|
|
40374
|
+
if (def && mod === "next/link") out2.add(def);
|
|
40375
|
+
for (const spec of (/\{([^}]*)\}/.exec(clause)?.[1] ?? "").split(",")) {
|
|
40376
|
+
const [imported, local] = spec.replace(/^\s*type\s+/, "").trim().split(/\s+as\s+/);
|
|
40377
|
+
if (imported && LINK_EXPORTS.has(imported.trim())) out2.add((local ?? imported).trim());
|
|
40378
|
+
}
|
|
40379
|
+
}
|
|
40380
|
+
linkCache.set(doc, out2);
|
|
40381
|
+
return out2;
|
|
40382
|
+
}
|
|
40383
|
+
function rendersNativeLink(doc, el) {
|
|
40384
|
+
const dest = (name2) => (boundAttr(el, name2) ?? "").trim() !== "";
|
|
40385
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy") return false;
|
|
40386
|
+
return routerLinkLocals(doc).has(el.tag) && (dest("href") || dest("to"));
|
|
40387
|
+
}
|
|
40362
40388
|
|
|
40363
40389
|
// src/rules/rendered.ts
|
|
40364
40390
|
import { readFileSync as readFileSync15 } from "fs";
|
|
@@ -49619,7 +49645,8 @@ var SUBJECTS = {
|
|
|
49619
49645
|
// Pointer, touch, gesture and drag handlers — everything a keyboard may not reach.
|
|
49620
49646
|
pointerHandlers: (docs) => docs.flatMap((d) => [
|
|
49621
49647
|
...d.elements.filter(
|
|
49622
|
-
(e) => !INTERACTIVE_TAGS.includes(e.tag) &&
|
|
49648
|
+
(e) => !INTERACTIVE_TAGS.includes(e.tag) && !rendersNativeLink(d, e) && // Next's <Link href> IS an <a href> (#133)
|
|
49649
|
+
Object.keys(e.attribs).some((k) => /^on(click|mousedown|mouseup|mouseenter|pointerdown|touchstart)$/i.test(k))
|
|
49623
49650
|
).map((e) => h(d, e, `<${e.tag}> carries a pointer handler but is not natively interactive \u2014 keyboard equivalent?`, `clickable|${e.tag}|${t(e, 40)}`)),
|
|
49624
49651
|
...linesOf(d, /\bon(?:MouseDown|PointerDown|TouchStart)\s*=/).map(
|
|
49625
49652
|
(l) => hAt(d, l.line, "handler", `down-event handler (action must not fire on DOWN, or must be abortable): ${l.text}`, `downevent|${l.text}`)
|
|
@@ -52440,6 +52467,12 @@ var emptyHeading = {
|
|
|
52440
52467
|
}
|
|
52441
52468
|
};
|
|
52442
52469
|
var DL_ALLOWED = /* @__PURE__ */ new Set(["dt", "dd", "div", "script", "template", "slot", "#fragment"]);
|
|
52470
|
+
function groupParentUnknown(doc, el) {
|
|
52471
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy" && doc.kind !== "sfc") return false;
|
|
52472
|
+
let p = el.parent;
|
|
52473
|
+
while (p && (p.tag === "div" || p.tag === "#fragment")) p = p.parent;
|
|
52474
|
+
return p === null || doc.kind === "sfc" && p.tag === "template" && p.parent === null;
|
|
52475
|
+
}
|
|
52443
52476
|
var dlStructure = {
|
|
52444
52477
|
id: "dl-structure",
|
|
52445
52478
|
criteria: ["1.3.1"],
|
|
@@ -52459,6 +52492,7 @@ var dlStructure = {
|
|
|
52459
52492
|
if (el.tag !== "dt" && el.tag !== "dd") continue;
|
|
52460
52493
|
const chain = ancestors(el);
|
|
52461
52494
|
if (chain.some((a) => a.tag === "dl" || !isIntrinsic(a.tag))) continue;
|
|
52495
|
+
if (groupParentUnknown(doc, el)) continue;
|
|
52462
52496
|
out2.push({ criteriaId: "1.3.1", el, msgId: "dl-structure.orphan", params: { tag: el.tag } });
|
|
52463
52497
|
}
|
|
52464
52498
|
return out2;
|
|
@@ -54723,10 +54757,14 @@ var crossPropDrilledNameLost = {
|
|
|
54723
54757
|
const findings = [];
|
|
54724
54758
|
for (const el of doc.elements) {
|
|
54725
54759
|
if (!isComponentUsage(el)) continue;
|
|
54726
|
-
const
|
|
54727
|
-
if (!
|
|
54760
|
+
const given = NAME_PROPS_PASSED.filter((p) => (attr(el, p) ?? "").trim() !== "");
|
|
54761
|
+
if (!given.length) continue;
|
|
54728
54762
|
const def = resolveUsage(graph, doc.file, el.tag);
|
|
54729
54763
|
if (!def?.hasControl || def.acceptsName || def.controlHasName) continue;
|
|
54764
|
+
const reads = def.readsProps;
|
|
54765
|
+
if (!reads) continue;
|
|
54766
|
+
const passed = given.find((p) => !reads.includes(p));
|
|
54767
|
+
if (!passed) continue;
|
|
54730
54768
|
findings.push({
|
|
54731
54769
|
criteriaId: "4.1.2",
|
|
54732
54770
|
el,
|
|
@@ -55009,6 +55047,62 @@ function findControl(fnNode) {
|
|
|
55009
55047
|
function posOf(node) {
|
|
55010
55048
|
return { line: node.loc?.start.line ?? 1, col: (node.loc?.start.column ?? 0) + 1 };
|
|
55011
55049
|
}
|
|
55050
|
+
function referencedNames(body3) {
|
|
55051
|
+
const skip = /* @__PURE__ */ new Set();
|
|
55052
|
+
const out2 = [];
|
|
55053
|
+
walkAst(body3, (n) => {
|
|
55054
|
+
if ((n.type === "MemberExpression" || n.type === "OptionalMemberExpression") && !n.computed) {
|
|
55055
|
+
const prop = asNode(n.property);
|
|
55056
|
+
if (prop) skip.add(prop);
|
|
55057
|
+
} else if ((n.type === "ObjectProperty" || n.type === "ObjectMethod") && !n.computed && !n.shorthand) {
|
|
55058
|
+
const key2 = asNode(n.key);
|
|
55059
|
+
if (key2) skip.add(key2);
|
|
55060
|
+
} else if (n.type === "Identifier" && !skip.has(n)) out2.push(n);
|
|
55061
|
+
});
|
|
55062
|
+
return out2;
|
|
55063
|
+
}
|
|
55064
|
+
function identName(n) {
|
|
55065
|
+
return n?.type === "Identifier" && typeof n.name === "string" ? n.name : "";
|
|
55066
|
+
}
|
|
55067
|
+
function readsProps(fnNode) {
|
|
55068
|
+
let param = asNodes(fnNode.params)[0];
|
|
55069
|
+
if (!param) return [];
|
|
55070
|
+
if (param.type === "AssignmentPattern") param = asNode(param.left);
|
|
55071
|
+
const refs = referencedNames(fnNode.body);
|
|
55072
|
+
if (param?.type === "ObjectPattern") {
|
|
55073
|
+
const used2 = [];
|
|
55074
|
+
for (const prop of asNodes(param.properties)) {
|
|
55075
|
+
if (prop.type === "RestElement") {
|
|
55076
|
+
const rest = identName(asNode(prop.argument));
|
|
55077
|
+
if (!rest || refs.some((r) => r.name === rest)) return null;
|
|
55078
|
+
continue;
|
|
55079
|
+
}
|
|
55080
|
+
const key2 = asNode(prop.key);
|
|
55081
|
+
const keyName = identName(key2) || (key2?.type === "StringLiteral" && typeof key2.value === "string" ? key2.value : "");
|
|
55082
|
+
if (prop.type !== "ObjectProperty" || prop.computed || !keyName) return null;
|
|
55083
|
+
let value = asNode(prop.value);
|
|
55084
|
+
if (value?.type === "AssignmentPattern") value = asNode(value.left);
|
|
55085
|
+
const local = identName(value);
|
|
55086
|
+
if (!local) return null;
|
|
55087
|
+
if (refs.some((r) => r.name === local)) used2.push(keyName);
|
|
55088
|
+
}
|
|
55089
|
+
return used2;
|
|
55090
|
+
}
|
|
55091
|
+
const whole = identName(param);
|
|
55092
|
+
if (!whole) return null;
|
|
55093
|
+
const used = [];
|
|
55094
|
+
const members = /* @__PURE__ */ new Set();
|
|
55095
|
+
walkAst(fnNode.body, (n) => {
|
|
55096
|
+
if (n.type !== "MemberExpression" && n.type !== "OptionalMemberExpression" || n.computed) return;
|
|
55097
|
+
const obj2 = asNode(n.object);
|
|
55098
|
+
const prop = identName(asNode(n.property));
|
|
55099
|
+
if (obj2 && identName(obj2) === whole && prop) {
|
|
55100
|
+
members.add(obj2);
|
|
55101
|
+
used.push(prop);
|
|
55102
|
+
}
|
|
55103
|
+
});
|
|
55104
|
+
return refs.some((r) => r.name === whole && !members.has(r)) ? null : used;
|
|
55105
|
+
}
|
|
55012
55106
|
function analyzeComponent(name2, file, fnNode) {
|
|
55013
55107
|
const control = findControl(fnNode);
|
|
55014
55108
|
if (!control) {
|
|
@@ -55035,7 +55129,19 @@ function analyzeComponent(name2, file, fnNode) {
|
|
|
55035
55129
|
const acceptsName = spreadsProps || forwardsAria || acceptsNameViaChildren;
|
|
55036
55130
|
const controlHasName = literalAriaName || forwardsAria || hasLiteralText(control);
|
|
55037
55131
|
const rendersIconOnlyControl = hasIconChild2(control) && !hasLiteralText(control) && !literalAriaName && !forwardsAria;
|
|
55038
|
-
return {
|
|
55132
|
+
return {
|
|
55133
|
+
name: name2,
|
|
55134
|
+
file,
|
|
55135
|
+
line,
|
|
55136
|
+
col,
|
|
55137
|
+
hasControl: true,
|
|
55138
|
+
rendersIconOnlyControl,
|
|
55139
|
+
acceptsName,
|
|
55140
|
+
controlHasName,
|
|
55141
|
+
spreadsProps,
|
|
55142
|
+
forwardsAria,
|
|
55143
|
+
readsProps: readsProps(fnNode)
|
|
55144
|
+
};
|
|
55039
55145
|
}
|
|
55040
55146
|
function pascalCaseBasename(posix3) {
|
|
55041
55147
|
const base = (posix3.split("/").pop() ?? posix3).replace(/\.[^.]+$/, "");
|
|
@@ -27,7 +27,7 @@ variables:
|
|
|
27
27
|
ULTRA11Y_LANG: en
|
|
28
28
|
# Exact by default: a CI report must say which engine produced it. The release script keeps
|
|
29
29
|
# this pin aligned with the package version; override only for a deliberate upgrade test.
|
|
30
|
-
ULTRA11Y_VERSION: '5.57.
|
|
30
|
+
ULTRA11Y_VERSION: '5.57.5'
|
|
31
31
|
# Batches of 8 amortise the prompt; each accepted verdict is checkpointed before the next
|
|
32
32
|
# batch, and later passes receive only the residue.
|
|
33
33
|
ULTRA11Y_GRAIN: batch
|
|
@@ -28,6 +28,7 @@ import { parseInlineStyle } from "./color.js";
|
|
|
28
28
|
import type { Evidence } from "./adjudicate.js";
|
|
29
29
|
import { AXE_WCAG } from "./axe-map.js";
|
|
30
30
|
import { computedTextPairs, renderedRulesFor, renderedRulesRan } from "./rules/rendered.js";
|
|
31
|
+
import { rendersNativeLink } from "./rules/rule.js";
|
|
31
32
|
|
|
32
33
|
/** Mask the parts of a text that change between runs without the code changing.
|
|
33
34
|
*
|
|
@@ -1487,7 +1488,9 @@ export const SUBJECTS: Record<string, Subject> = {
|
|
|
1487
1488
|
...d.elements
|
|
1488
1489
|
.filter(
|
|
1489
1490
|
(e) =>
|
|
1490
|
-
!INTERACTIVE_TAGS.includes(e.tag) &&
|
|
1491
|
+
!INTERACTIVE_TAGS.includes(e.tag) &&
|
|
1492
|
+
!rendersNativeLink(d, e) && // Next's <Link href> IS an <a href> (#133)
|
|
1493
|
+
Object.keys(e.attribs).some((k) => /^on(click|mousedown|mouseup|mouseenter|pointerdown|touchstart)$/i.test(k)),
|
|
1491
1494
|
)
|
|
1492
1495
|
.map((e) => h(d, e, `<${e.tag}> carries a pointer handler but is not natively interactive — keyboard equivalent?`, `clickable|${e.tag}|${t(e, 40)}`)),
|
|
1493
1496
|
...linesOf(d, /\bon(?:MouseDown|PointerDown|TouchStart)\s*=/).map((l) =>
|
package/src/graph/imports.ts
CHANGED
|
@@ -27,6 +27,11 @@ export interface ComponentDef {
|
|
|
27
27
|
controlHasName: boolean; // control already bears a literal name (text or literal aria-label) — a passed name prop is dead, not lost
|
|
28
28
|
spreadsProps: boolean; // control has {...props}
|
|
29
29
|
forwardsAria: boolean; // control has aria-label/labelledby set to an expression
|
|
30
|
+
// The props the component body READS (a destructured binding it references, or a
|
|
31
|
+
// `props.x` access); null when that cannot be told (a rest/whole `props` object that
|
|
32
|
+
// travels on, a nested pattern…). Set only on a control-rendering component: a name prop
|
|
33
|
+
// it reads went somewhere — a <caption>, a heading — so it was not lost at the boundary.
|
|
34
|
+
readsProps?: string[] | null;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export interface FileGraphNode {
|
|
@@ -127,6 +132,70 @@ function posOf(node: AstNode): { line: number; col: number } {
|
|
|
127
132
|
return { line: node.loc?.start.line ?? 1, col: (node.loc?.start.column ?? 0) + 1 };
|
|
128
133
|
}
|
|
129
134
|
|
|
135
|
+
// Every identifier the body references as a value — not a non-computed member property
|
|
136
|
+
// (`file.name`) nor a non-computed object key (`{ title: x }`). Over-collecting only makes
|
|
137
|
+
// a prop look read, which silences the rule: the conservative direction.
|
|
138
|
+
function referencedNames(body: unknown): AstNode[] {
|
|
139
|
+
const skip = new Set<AstNode>();
|
|
140
|
+
const out: AstNode[] = [];
|
|
141
|
+
walkAst(body, (n) => {
|
|
142
|
+
if ((n.type === "MemberExpression" || n.type === "OptionalMemberExpression") && !n.computed) {
|
|
143
|
+
const prop = asNode(n.property);
|
|
144
|
+
if (prop) skip.add(prop);
|
|
145
|
+
} else if ((n.type === "ObjectProperty" || n.type === "ObjectMethod") && !n.computed && !n.shorthand) {
|
|
146
|
+
const key = asNode(n.key);
|
|
147
|
+
if (key) skip.add(key);
|
|
148
|
+
} else if (n.type === "Identifier" && !skip.has(n)) out.push(n);
|
|
149
|
+
});
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function identName(n: AstNode | undefined): string {
|
|
154
|
+
return n?.type === "Identifier" && typeof n.name === "string" ? n.name : "";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Which props does the component read? See ComponentDef.readsProps.
|
|
158
|
+
function readsProps(fnNode: AstNode): string[] | null {
|
|
159
|
+
let param = asNodes(fnNode.params)[0];
|
|
160
|
+
if (!param) return []; // takes no props: whatever is passed is dropped
|
|
161
|
+
if (param.type === "AssignmentPattern") param = asNode(param.left);
|
|
162
|
+
const refs = referencedNames(fnNode.body);
|
|
163
|
+
if (param?.type === "ObjectPattern") {
|
|
164
|
+
const used: string[] = [];
|
|
165
|
+
for (const prop of asNodes(param.properties)) {
|
|
166
|
+
if (prop.type === "RestElement") {
|
|
167
|
+
const rest = identName(asNode(prop.argument));
|
|
168
|
+
if (!rest || refs.some((r) => r.name === rest)) return null; // the rest travels on: any prop may
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const key = asNode(prop.key);
|
|
172
|
+
const keyName = identName(key) || (key?.type === "StringLiteral" && typeof key.value === "string" ? key.value : "");
|
|
173
|
+
if (prop.type !== "ObjectProperty" || prop.computed || !keyName) return null;
|
|
174
|
+
let value = asNode(prop.value);
|
|
175
|
+
if (value?.type === "AssignmentPattern") value = asNode(value.left);
|
|
176
|
+
const local = identName(value);
|
|
177
|
+
if (!local) return null; // nested pattern
|
|
178
|
+
if (refs.some((r) => r.name === local)) used.push(keyName);
|
|
179
|
+
}
|
|
180
|
+
return used;
|
|
181
|
+
}
|
|
182
|
+
const whole = identName(param);
|
|
183
|
+
if (!whole) return null;
|
|
184
|
+
const used: string[] = [];
|
|
185
|
+
const members = new Set<AstNode>();
|
|
186
|
+
walkAst(fnNode.body, (n) => {
|
|
187
|
+
if ((n.type !== "MemberExpression" && n.type !== "OptionalMemberExpression") || n.computed) return;
|
|
188
|
+
const obj = asNode(n.object);
|
|
189
|
+
const prop = identName(asNode(n.property));
|
|
190
|
+
if (obj && identName(obj) === whole && prop) {
|
|
191
|
+
members.add(obj);
|
|
192
|
+
used.push(prop);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
// `props` used any other way (spread, passed on, destructured in the body) → cannot tell.
|
|
196
|
+
return refs.some((r) => r.name === whole && !members.has(r)) ? null : used;
|
|
197
|
+
}
|
|
198
|
+
|
|
130
199
|
function analyzeComponent(name: string, file: string, fnNode: AstNode): ComponentDef {
|
|
131
200
|
const control = findControl(fnNode);
|
|
132
201
|
if (!control) {
|
|
@@ -157,7 +226,19 @@ function analyzeComponent(name: string, file: string, fnNode: AstNode): Componen
|
|
|
157
226
|
// icon button like `aria-label={isPlus ? "…" : "…"}`.
|
|
158
227
|
const controlHasName = literalAriaName || forwardsAria || hasLiteralText(control);
|
|
159
228
|
const rendersIconOnlyControl = hasIconChild(control) && !hasLiteralText(control) && !literalAriaName && !forwardsAria;
|
|
160
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
name,
|
|
231
|
+
file,
|
|
232
|
+
line,
|
|
233
|
+
col,
|
|
234
|
+
hasControl: true,
|
|
235
|
+
rendersIconOnlyControl,
|
|
236
|
+
acceptsName,
|
|
237
|
+
controlHasName,
|
|
238
|
+
spreadsProps,
|
|
239
|
+
forwardsAria,
|
|
240
|
+
readsProps: readsProps(fnNode),
|
|
241
|
+
};
|
|
161
242
|
}
|
|
162
243
|
|
|
163
244
|
// A .vue/.svelte/.astro SFC has no top-level JS function to declare "the component"
|
|
@@ -140,13 +140,20 @@ const crossPropDrilledNameLost: CrossRule = {
|
|
|
140
140
|
const findings = [];
|
|
141
141
|
for (const el of doc.elements) {
|
|
142
142
|
if (!isComponentUsage(el)) continue;
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
143
|
+
const given = NAME_PROPS_PASSED.filter((p) => (attr(el, p) ?? "").trim() !== "");
|
|
144
|
+
if (!given.length) continue;
|
|
145
145
|
const def = resolveUsage(graph, doc.file, el.tag);
|
|
146
146
|
// Fire only when the control would otherwise be NAMELESS: it must render a control,
|
|
147
147
|
// not accept a name from props, AND not already carry a literal name (else the passed
|
|
148
148
|
// prop is dead code, not a real 4.1.2 non-conformity).
|
|
149
149
|
if (!def?.hasControl || def.acceptsName || def.controlHasName) continue;
|
|
150
|
+
// …and only for a name prop the component provably never reads. One it reads went
|
|
151
|
+
// somewhere — egapro's SelectedFilesTable renders its `title` as the <caption> (#133);
|
|
152
|
+
// when what it reads cannot be told, nothing is proven lost.
|
|
153
|
+
const reads = def.readsProps;
|
|
154
|
+
if (!reads) continue;
|
|
155
|
+
const passed = given.find((p) => !reads.includes(p));
|
|
156
|
+
if (!passed) continue;
|
|
150
157
|
findings.push({
|
|
151
158
|
criteriaId: "4.1.2",
|
|
152
159
|
el,
|
package/src/rules/headings.ts
CHANGED
|
@@ -222,6 +222,17 @@ const emptyHeading: Rule = {
|
|
|
222
222
|
// nothing outside a <dl>. Broken either way, the relationship is purely visual.
|
|
223
223
|
const DL_ALLOWED = new Set(["dt", "dd", "div", "script", "template", "slot", "#fragment"]);
|
|
224
224
|
|
|
225
|
+
/** A <dt>/<dd> reached only through <div> groups (which a <dl> admits) and fragments, up to
|
|
226
|
+
* the root of a returned JSX expression (or an SFC's <template>), is placed by the caller:
|
|
227
|
+
* egapro's `<dl><InfoRow/></dl>`, InfoRow returning `<div><dt/><dd/></div>` (#133). Its
|
|
228
|
+
* parent is unknown, not missing. An HTML file has no caller, so its root stays decisive. */
|
|
229
|
+
function groupParentUnknown(doc: Doc, el: El): boolean {
|
|
230
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy" && doc.kind !== "sfc") return false;
|
|
231
|
+
let p = el.parent;
|
|
232
|
+
while (p && (p.tag === "div" || p.tag === "#fragment")) p = p.parent;
|
|
233
|
+
return p === null || (doc.kind === "sfc" && p.tag === "template" && p.parent === null);
|
|
234
|
+
}
|
|
235
|
+
|
|
225
236
|
const dlStructure: Rule = {
|
|
226
237
|
id: "dl-structure",
|
|
227
238
|
criteria: ["1.3.1"],
|
|
@@ -241,6 +252,7 @@ const dlStructure: Rule = {
|
|
|
241
252
|
if (el.tag !== "dt" && el.tag !== "dd") continue;
|
|
242
253
|
const chain = ancestors(el);
|
|
243
254
|
if (chain.some((a) => a.tag === "dl" || !isIntrinsic(a.tag))) continue; // inside a dl, or a component may supply one
|
|
255
|
+
if (groupParentUnknown(doc, el)) continue;
|
|
244
256
|
out.push({ criteriaId: "1.3.1", el, msgId: "dl-structure.orphan", params: { tag: el.tag } });
|
|
245
257
|
}
|
|
246
258
|
return out;
|
package/src/rules/rule.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Kept dependency-light (no value import of the registry) to avoid cycles.
|
|
3
3
|
import type { Doc, El } from "../parse/html.js";
|
|
4
4
|
import type { Finding, Severity } from "../types.js";
|
|
5
|
-
import { snippet, textContent, elementsByTag } from "../parse/html.js";
|
|
5
|
+
import { snippet, textContent, elementsByTag, boundAttr } from "../parse/html.js";
|
|
6
6
|
import { MSG_CATALOG, type MsgParams } from "../messages.js";
|
|
7
7
|
|
|
8
8
|
// A build-time / runtime content-injection placeholder left in a framework SHELL
|
|
@@ -126,3 +126,40 @@ export function toFinding(doc: Doc, ruleId: string, def: Severity, rf: RuleFindi
|
|
|
126
126
|
...((rf.advisory ?? ruleAdvisory) ? { advisory: true } : {}),
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
+
|
|
130
|
+
// Router link components that render a native <a href> (Next's `Link`, React Router's
|
|
131
|
+
// `Link`/`NavLink`…): a pointer handler on one sits on a link, keyboard-operable by nature.
|
|
132
|
+
const LINK_MODULE = /^(?:next\/link|react-router(?:-dom)?|@remix-run\/react|gatsby|@tanstack\/[\w-]*router)$/;
|
|
133
|
+
const LINK_EXPORTS = new Set(["Link", "NavLink"]);
|
|
134
|
+
const linkCache = new WeakMap<Doc, Set<string>>();
|
|
135
|
+
|
|
136
|
+
/** The local names this file binds to a router link component, read from its imports. */
|
|
137
|
+
function routerLinkLocals(doc: Doc): Set<string> {
|
|
138
|
+
const hit = linkCache.get(doc);
|
|
139
|
+
if (hit) return hit;
|
|
140
|
+
const out = new Set<string>();
|
|
141
|
+
for (const m of doc.source.matchAll(/(?:^|[\n;])\s*import\s+(?!type\b)([^;'"]*?)\s+from\s+["']([^"']+)["']/g)) {
|
|
142
|
+
const clause = m[1] ?? "";
|
|
143
|
+
const mod = m[2] ?? "";
|
|
144
|
+
if (!LINK_MODULE.test(mod)) continue;
|
|
145
|
+
const def = /^\s*([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(clause)?.[1];
|
|
146
|
+
if (def && mod === "next/link") out.add(def);
|
|
147
|
+
for (const spec of (/\{([^}]*)\}/.exec(clause)?.[1] ?? "").split(",")) {
|
|
148
|
+
const [imported, local] = spec
|
|
149
|
+
.replace(/^\s*type\s+/, "")
|
|
150
|
+
.trim()
|
|
151
|
+
.split(/\s+as\s+/);
|
|
152
|
+
if (imported && LINK_EXPORTS.has(imported.trim())) out.add((local ?? imported).trim());
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
linkCache.set(doc, out);
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Does this element render a native link — a router link component given a destination?
|
|
160
|
+
* A component of unknown origin proves nothing and stays non-native. */
|
|
161
|
+
export function rendersNativeLink(doc: Doc, el: El): boolean {
|
|
162
|
+
const dest = (name: string): boolean => (boundAttr(el, name) ?? "").trim() !== "";
|
|
163
|
+
if (doc.kind !== "jsx-ast" && doc.kind !== "jsx-lossy") return false;
|
|
164
|
+
return routerLinkLocals(doc).has(el.tag) && (dest("href") || dest("to"));
|
|
165
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Single source of truth for shared types + the embedded version. sync-version.mjs
|
|
2
2
|
// rewrites VERSION at release time (kept in lockstep with package.json + SKILL.md).
|
|
3
|
-
export const VERSION = "5.57.
|
|
3
|
+
export const VERSION = "5.57.5";
|
|
4
4
|
export const SCHEMA_VERSION = 2;
|
|
5
5
|
|
|
6
6
|
// Lang = the UI FRAME's language — the `L` localization tables each module (report,
|