@diegovelasquezweb/a11y-engine 0.11.2 → 0.11.4
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/package.json +1 -1
- package/src/index.mjs +1 -0
- package/src/pipeline/dom-scanner.mjs +38 -25
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -694,6 +694,7 @@ export async function runAudit(options) {
|
|
|
694
694
|
projectDir: options.projectDir,
|
|
695
695
|
remotePackageJson,
|
|
696
696
|
engines,
|
|
697
|
+
includeWarnings: options.includeWarnings ?? options.includeIncomplete ?? false,
|
|
697
698
|
clearCache: options.clearCache ?? false,
|
|
698
699
|
serverMode: options.serverMode ?? false,
|
|
699
700
|
},
|
|
@@ -1003,6 +1003,9 @@ async function runPa11yChecks(routeUrl, axeTags, sharedBrowser = null, includeWa
|
|
|
1003
1003
|
|
|
1004
1004
|
const results = await pa11y(routeUrl, pa11yOptions);
|
|
1005
1005
|
|
|
1006
|
+
// Group issues by ruleId so each rule produces one violation (axe-style)
|
|
1007
|
+
const groupedByRule = new Map();
|
|
1008
|
+
|
|
1006
1009
|
for (const issue of results.issues || []) {
|
|
1007
1010
|
if (issue.type === "notice") continue;
|
|
1008
1011
|
|
|
@@ -1027,34 +1030,44 @@ async function runPa11yChecks(routeUrl, axeTags, sharedBrowser = null, includeWa
|
|
|
1027
1030
|
const ruleId = axeEquivId || `pa11y-${((issue.code || "unknown").split(".").pop() || "unknown").toLowerCase()}`;
|
|
1028
1031
|
const originalCode = issue.code || "unknown";
|
|
1029
1032
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
helpUrl: wcagCriterion
|
|
1037
|
-
? `https://www.w3.org/WAI/WCAG21/Understanding/${wcagCriterion.replace(/\./g, "")}`
|
|
1038
|
-
: "https://squizlabs.github.io/HTML_CodeSniffer/",
|
|
1039
|
-
source: "pa11y",
|
|
1040
|
-
source_rule_id: originalCode,
|
|
1041
|
-
nodes: [{
|
|
1042
|
-
any: [],
|
|
1043
|
-
all: [{
|
|
1044
|
-
id: "pa11y-check",
|
|
1045
|
-
data: { code: originalCode, context: issue.context?.slice(0, 200) },
|
|
1046
|
-
relatedNodes: [],
|
|
1047
|
-
impact,
|
|
1048
|
-
message: issue.message || "",
|
|
1049
|
-
}],
|
|
1050
|
-
none: [],
|
|
1033
|
+
const node = {
|
|
1034
|
+
any: [],
|
|
1035
|
+
all: [{
|
|
1036
|
+
id: "pa11y-check",
|
|
1037
|
+
data: { code: originalCode, context: issue.context?.slice(0, 200) },
|
|
1038
|
+
relatedNodes: [],
|
|
1051
1039
|
impact,
|
|
1052
|
-
|
|
1053
|
-
target: issue.selector ? [issue.selector] : [],
|
|
1054
|
-
failureSummary: `Fix all of the following:\n ${issue.message || "Accessibility issue"}`,
|
|
1040
|
+
message: issue.message || "",
|
|
1055
1041
|
}],
|
|
1056
|
-
|
|
1042
|
+
none: [],
|
|
1043
|
+
impact,
|
|
1044
|
+
html: issue.context || "",
|
|
1045
|
+
target: issue.selector ? [issue.selector] : [],
|
|
1046
|
+
failureSummary: `Fix all of the following:\n ${issue.message || "Accessibility issue"}`,
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
if (groupedByRule.has(ruleId)) {
|
|
1050
|
+
// Add node to existing violation
|
|
1051
|
+
groupedByRule.get(ruleId).nodes.push(node);
|
|
1052
|
+
} else {
|
|
1053
|
+
// Create new violation for this rule
|
|
1054
|
+
groupedByRule.set(ruleId, {
|
|
1055
|
+
id: ruleId,
|
|
1056
|
+
impact,
|
|
1057
|
+
tags: ["pa11y-check", ...(wcagCriterion ? [`wcag${wcagCriterion.replace(/\./g, "")}`] : [])],
|
|
1058
|
+
description: issue.message || "pa11y detected an accessibility issue",
|
|
1059
|
+
help: issue.message?.split(".")[0] || "Accessibility issue detected by HTML CodeSniffer",
|
|
1060
|
+
helpUrl: wcagCriterion
|
|
1061
|
+
? `https://www.w3.org/WAI/WCAG21/Understanding/${wcagCriterion.replace(/\./g, "")}`
|
|
1062
|
+
: "https://squizlabs.github.io/HTML_CodeSniffer/",
|
|
1063
|
+
source: "pa11y",
|
|
1064
|
+
source_rule_id: originalCode,
|
|
1065
|
+
nodes: [node],
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1057
1068
|
}
|
|
1069
|
+
|
|
1070
|
+
violations.push(...groupedByRule.values());
|
|
1058
1071
|
} catch (err) {
|
|
1059
1072
|
log.warn(`pa11y checks failed (non-fatal): ${err.message}`);
|
|
1060
1073
|
}
|