@surea11y/core 1.3.0 → 1.4.0

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +46 -2
  2. package/README.md +109 -35
  3. package/bin/surea11y-core.js +20 -0
  4. package/docs/API_STABILITY.md +26 -0
  5. package/docs/CI_INTEGRATIONS.md +7 -7
  6. package/docs/ENGINE_OPTIONS.md +1 -1
  7. package/docs/I18N.md +12 -9
  8. package/docs/INTEGRATION.md +1 -1
  9. package/docs/LIMITATIONS.md +1 -1
  10. package/docs/REPORT.md +1 -1
  11. package/package.json +50 -16
  12. package/src/baseline.js +0 -0
  13. package/src/checks/automatic/area-alt-present.js +4 -6
  14. package/src/checks/automatic/aria-allowed-attr.js +15 -51
  15. package/src/checks/automatic/aria-allowed-role.js +2 -0
  16. package/src/checks/automatic/aria-braille-equivalent.js +2 -0
  17. package/src/checks/automatic/aria-conditional-attr.js +8 -7
  18. package/src/checks/automatic/aria-deprecated-role.js +4 -3
  19. package/src/checks/automatic/aria-hidden-body.js +6 -4
  20. package/src/checks/automatic/aria-hidden-focus.js +12 -13
  21. package/src/checks/automatic/aria-prohibited-attr.js +98 -105
  22. package/src/checks/automatic/aria-prohibited-children.js +56 -87
  23. package/src/checks/automatic/aria-required-attr.js +6 -7
  24. package/src/checks/automatic/aria-required-children.js +7 -10
  25. package/src/checks/automatic/aria-required-parent.js +20 -25
  26. package/src/checks/automatic/aria-role-name-present.js +2 -0
  27. package/src/checks/automatic/aria-roles-valid.js +2 -0
  28. package/src/checks/automatic/aria-valid-attr-value.js +18 -15
  29. package/src/checks/automatic/aria-valid-attr.js +2 -0
  30. package/src/checks/automatic/autocomplete-valid.js +2 -0
  31. package/src/checks/automatic/avoid-inline-spacing.js +3 -2
  32. package/src/checks/automatic/binary-control-name-present.js +2 -0
  33. package/src/checks/automatic/button-name-present.js +7 -7
  34. package/src/checks/automatic/bypass-blocks-present.js +9 -7
  35. package/src/checks/automatic/canvas-text-alternative-present.js +2 -0
  36. package/src/checks/automatic/combobox-name-present.js +2 -0
  37. package/src/checks/automatic/contrast-computable.js +2 -0
  38. package/src/checks/automatic/contrast-enhanced.js +2 -0
  39. package/src/checks/automatic/contrast-minimum.js +2 -0
  40. package/src/checks/automatic/css-orientation-lock.js +21 -27
  41. package/src/checks/automatic/definition-list-children-valid.js +6 -6
  42. package/src/checks/automatic/deprecated-elements-not-used.js +4 -2
  43. package/src/checks/automatic/dialog-name-present.js +10 -10
  44. package/src/checks/automatic/dlitem-parent-valid.js +2 -0
  45. package/src/checks/automatic/duplicate-id-aria.js +4 -3
  46. package/src/checks/automatic/embed-text-alternative-present.js +2 -0
  47. package/src/checks/automatic/form-control-programmatic-label-present.js +2 -0
  48. package/src/checks/automatic/form-control-single-label.js +6 -7
  49. package/src/checks/automatic/html-xml-lang-mismatch.js +2 -0
  50. package/src/checks/automatic/iframe-focusable-content.js +246 -18
  51. package/src/checks/automatic/iframe-name-present.js +2 -0
  52. package/src/checks/automatic/iframe-title-unique.js +3 -1
  53. package/src/checks/automatic/img-alt-present.js +7 -9
  54. package/src/checks/automatic/input-image-alt-present.js +4 -6
  55. package/src/checks/automatic/label-in-name.js +15 -19
  56. package/src/checks/automatic/language-page-present.js +2 -0
  57. package/src/checks/automatic/link-in-text-block.js +2 -0
  58. package/src/checks/automatic/link-name-present.js +2 -0
  59. package/src/checks/automatic/list-children-valid.js +14 -24
  60. package/src/checks/automatic/listbox-name-present.js +2 -0
  61. package/src/checks/automatic/listitem-parent-valid.js +30 -7
  62. package/src/checks/automatic/menuitem-name-present.js +2 -0
  63. package/src/checks/automatic/meta-refresh-no-exceptions.js +4 -4
  64. package/src/checks/automatic/meta-refresh-timing-absent.js +2 -0
  65. package/src/checks/automatic/meta-viewport-zoom-enabled.js +2 -0
  66. package/src/checks/automatic/meter-name-present.js +4 -3
  67. package/src/checks/automatic/nested-interactive-controls-absent.js +27 -5
  68. package/src/checks/automatic/object-text-alternative-present.js +2 -0
  69. package/src/checks/automatic/option-name-present.js +2 -0
  70. package/src/checks/automatic/page-title-present.js +2 -0
  71. package/src/checks/automatic/progressbar-name-present.js +8 -10
  72. package/src/checks/automatic/role-img-alt-present.js +4 -4
  73. package/src/checks/automatic/searchbox-name-present.js +2 -0
  74. package/src/checks/automatic/server-side-image-map-absent.js +4 -3
  75. package/src/checks/automatic/slider-name-present.js +2 -0
  76. package/src/checks/automatic/spinbutton-name-present.js +2 -0
  77. package/src/checks/automatic/summary-name-present.js +2 -0
  78. package/src/checks/automatic/svg-image-text-alternative-present.js +2 -0
  79. package/src/checks/automatic/svg-text-alternative-present.js +17 -5
  80. package/src/checks/automatic/tab-name-present.js +2 -0
  81. package/src/checks/automatic/table-headers-attr-valid.js +3 -2
  82. package/src/checks/automatic/table-th-has-data-cells.js +2 -0
  83. package/src/checks/automatic/target-size-minimum.js +5 -0
  84. package/src/checks/automatic/td-has-header.js +24 -1
  85. package/src/checks/automatic/textbox-name-present.js +2 -0
  86. package/src/checks/automatic/tooltip-name-present.js +2 -0
  87. package/src/checks/automatic/treeitem-name-present.js +2 -0
  88. package/src/checks/automatic/valid-lang.js +2 -0
  89. package/src/checks/automatic/video-poster-text-alternative-present.js +2 -0
  90. package/src/checks/manual/accesskeys-manual.js +3 -1
  91. package/src/checks/manual/area-alt-decorative-manual.js +2 -0
  92. package/src/checks/manual/area-alt-quality-manual.js +2 -0
  93. package/src/checks/manual/aria-checked-state-mismatch-manual.js +14 -23
  94. package/src/checks/manual/aria-text-manual.js +6 -5
  95. package/src/checks/manual/canvas-text-alternative-quality-manual.js +2 -0
  96. package/src/checks/manual/css-hidden-focus.js +184 -9
  97. package/src/checks/manual/embed-text-alternative-quality-manual.js +18 -13
  98. package/src/checks/manual/empty-heading-manual.js +17 -17
  99. package/src/checks/manual/empty-table-header-manual.js +52 -25
  100. package/src/checks/manual/focus-order-semantics-manual.js +16 -4
  101. package/src/checks/manual/form-control-programmatic-label-quality-manual.js +2 -0
  102. package/src/checks/manual/heading-order-manual.js +28 -1
  103. package/src/checks/manual/identical-links-same-purpose-manual.js +2 -0
  104. package/src/checks/manual/image-redundant-alt-manual.js +21 -1
  105. package/src/checks/manual/img-alt-decorative-manual.js +2 -0
  106. package/src/checks/manual/img-alt-quality-manual.js +2 -0
  107. package/src/checks/manual/input-image-alt-decorative-manual.js +2 -0
  108. package/src/checks/manual/input-image-alt-quality-manual.js +2 -0
  109. package/src/checks/manual/label-title-only-manual.js +29 -22
  110. package/src/checks/manual/landmark-banner-is-top-level-manual.js +54 -47
  111. package/src/checks/manual/landmark-contentinfo-is-top-level-manual.js +42 -26
  112. package/src/checks/manual/landmark-main-is-top-level-manual.js +41 -24
  113. package/src/checks/manual/landmark-no-duplicate-banner-manual.js +16 -23
  114. package/src/checks/manual/landmark-no-duplicate-contentinfo-manual.js +14 -21
  115. package/src/checks/manual/landmark-no-duplicate-main-manual.js +10 -13
  116. package/src/checks/manual/landmark-one-main-manual.js +12 -23
  117. package/src/checks/manual/landmark-unique-manual.js +37 -52
  118. package/src/checks/manual/link-name-quality-manual.js +2 -0
  119. package/src/checks/manual/media-transcript-present-manual.js +2 -0
  120. package/src/checks/manual/meta-viewport-large-manual.js +3 -1
  121. package/src/checks/manual/mouse-only-event-handlers-manual.js +2 -0
  122. package/src/checks/manual/no-autoplay-audio-manual.js +2 -0
  123. package/src/checks/manual/object-text-alternative-quality-manual.js +2 -0
  124. package/src/checks/manual/p-as-heading-manual.js +2 -0
  125. package/src/checks/manual/page-has-heading-one-manual.js +12 -11
  126. package/src/checks/manual/page-title-patterns-manual.js +2 -0
  127. package/src/checks/manual/presentation-role-conflict-manual.js +51 -37
  128. package/src/checks/manual/region-manual.js +27 -36
  129. package/src/checks/manual/scope-attr-valid-manual.js +3 -1
  130. package/src/checks/manual/scrollable-region-focusable-manual.js +2 -0
  131. package/src/checks/manual/skip-link-manual.js +7 -6
  132. package/src/checks/manual/svg-text-alternative-quality-manual.js +2 -0
  133. package/src/checks/manual/tabindex-manual.js +3 -1
  134. package/src/checks/manual/table-duplicate-name-manual.js +5 -4
  135. package/src/checks/manual/table-fake-caption-manual.js +24 -3
  136. package/src/checks/manual/video-caption-manual.js +2 -0
  137. package/src/checks/manual-review.js +2 -0
  138. package/src/core.js +6772 -2158
  139. package/src/index.js +2 -0
  140. package/src/report.js +51 -9
  141. package/src/sarif.js +18 -3
  142. package/surea11y.browser.js +2731 -999
  143. package/bin/core.js +0 -473
  144. package/docs/CLI.md +0 -128
  145. package/src/catalogs/composites.wcag.js +0 -454
  146. package/src/checks/rules-and-tags.full.csv +0 -19
  147. package/src/checks/rules-and-tags.full.json +0 -259
  148. package/src/core/aria-helpers.js +0 -1211
  149. package/src/core/contrast-helpers.js +0 -1302
  150. package/src/core/dom-helpers.js +0 -4493
  151. package/src/core/dom-runner.js +0 -787
  152. package/src/core/frame-messaging.js +0 -261
  153. package/src/core/frame-scan.js +0 -190
  154. package/src/core/rollup-composites.js +0 -127
  155. package/src/core/rule-meta.js +0 -176
  156. package/src/coverage/wcag-facets.js +0 -1079
  157. package/src/coverage/wcag-version-map.js +0 -84
  158. package/src/i18n/en.js +0 -1228
  159. package/src/i18n/fr.js +0 -1185
  160. package/src/policy/contracts.js +0 -18
  161. package/src/policy/resolvePolicy.js +0 -59
  162. package/src/policy/schemas/engine-options.schema.json +0 -103
  163. package/src/policy/schemas/policy-contract.schema.json +0 -40
@@ -1,176 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Normalizes a rule module's `meta` export into the stable shape CHECK_DEFS
5
- * entries use everywhere else (build-time rules and runtime-registered
6
- * custom rules alike).
7
- *
8
- * Zero free vars (besides its own params) -- this gets inlined into the
9
- * generated core.js runtime via inlineConstFunction, the same mechanism
10
- * dom-helpers.js/dom-runner.js use, so it must stay self-contained/embeddable
11
- * via .toString(). engineTag is a param (not a closed-over module constant)
12
- * for exactly that reason.
13
- */
14
- function normalizeRuleMeta(ruleId, id, meta, engineTag) {
15
- function normalizeStringArray(value) {
16
- if (!Array.isArray(value)) return [];
17
- return value
18
- .map(String)
19
- .map((s) => s.trim())
20
- .filter(Boolean);
21
- }
22
-
23
- function normalizeObjectArray(value) {
24
- if (!Array.isArray(value)) return [];
25
- return value
26
- .filter((v) => v && typeof v === 'object' && !Array.isArray(v))
27
- .map((v) => ({ ...v }));
28
- }
29
-
30
- function deriveWcagScFromNormativeMappings(normativeMappings) {
31
- const nm = Array.isArray(normativeMappings) ? normativeMappings : [];
32
- const out = new Set();
33
- for (const m of nm) {
34
- if (!m || typeof m !== 'object') continue;
35
- if (String(m.standard || '').toUpperCase() !== 'WCAG') continue;
36
- const req = String(m.requirement || '').trim();
37
- if (req) out.add(req);
38
- }
39
- return Array.from(out).sort();
40
- }
41
-
42
- const m = meta && typeof meta === 'object' ? meta : {};
43
-
44
- const title = typeof m.title === 'string' && m.title.trim() ? m.title.trim() : id;
45
- const description = typeof m.description === 'string' ? m.description : '';
46
- const helpUrl = typeof m.helpUrl === 'string' ? m.helpUrl : '';
47
-
48
- const i18n =
49
- m.i18n && typeof m.i18n === 'object' && !Array.isArray(m.i18n) ? { ...m.i18n } : null;
50
-
51
- const tags = normalizeStringArray(m.tags).map((t) => t.toLowerCase());
52
- if (!tags.includes(engineTag)) tags.push(engineTag);
53
-
54
- const normativeMappings = normalizeObjectArray(m.normativeMappings);
55
- const wcagSc = deriveWcagScFromNormativeMappings(normativeMappings);
56
- const informativeReferences = normalizeObjectArray(m.informativeReferences);
57
-
58
- const defaultSeverity =
59
- typeof m.defaultSeverity === 'string' && m.defaultSeverity.trim()
60
- ? m.defaultSeverity.trim()
61
- : 'moderate';
62
-
63
- const defaultConfidence =
64
- typeof m.defaultConfidence === 'string' && m.defaultConfidence.trim()
65
- ? m.defaultConfidence.trim()
66
- : 'medium';
67
-
68
- const type = m.type === 'manual' || m.type === 'automatic' ? m.type : 'automatic';
69
-
70
- const coverage =
71
- m.coverage === null || typeof m.coverage === 'string' || typeof m.coverage === 'object'
72
- ? m.coverage
73
- : null;
74
-
75
- const ruleInterfaceVersion =
76
- typeof m.ruleInterfaceVersion === 'string' && m.ruleInterfaceVersion.trim()
77
- ? m.ruleInterfaceVersion.trim()
78
- : '1.0.0';
79
-
80
- const ruleVersion =
81
- typeof m.ruleVersion === 'string' && m.ruleVersion.trim() ? m.ruleVersion.trim() : '0.0.0';
82
-
83
- const normative = typeof m.normative === 'boolean' ? m.normative : true;
84
- const atomic = typeof m.atomic === 'boolean' ? m.atomic : true;
85
-
86
- // Deprecation signal for the rule catalog (see docs/API_STABILITY.md).
87
- // Purely informational -- a deprecated rule still runs and produces
88
- // results completely normally; this is a catalog-level migration signal
89
- // for integrators, not an automatic exclusion.
90
- const deprecated = typeof m.deprecated === 'boolean' ? m.deprecated : false;
91
- const deprecation =
92
- deprecated &&
93
- m.deprecation &&
94
- typeof m.deprecation === 'object' &&
95
- !Array.isArray(m.deprecation)
96
- ? {
97
- replacedBy:
98
- typeof m.deprecation.replacedBy === 'string' && m.deprecation.replacedBy.trim()
99
- ? m.deprecation.replacedBy.trim()
100
- : null,
101
- reason: typeof m.deprecation.reason === 'string' ? m.deprecation.reason.trim() : '',
102
- sinceVersion:
103
- typeof m.deprecation.sinceVersion === 'string' ? m.deprecation.sinceVersion.trim() : ''
104
- }
105
- : null;
106
-
107
- if (deprecated && (!deprecation || !deprecation.reason || !deprecation.sinceVersion)) {
108
- throw new Error(
109
- `Rule ${ruleId}: meta.deprecated:true requires meta.deprecation.reason and meta.deprecation.sinceVersion`
110
- );
111
- }
112
-
113
- const category = typeof m.category === 'string' && m.category.trim() ? m.category.trim() : null;
114
- const standard = typeof m.standard === 'string' && m.standard.trim() ? m.standard.trim() : null;
115
-
116
- const applicability = typeof m.applicability === 'string' ? m.applicability : '';
117
- const expectation = typeof m.expectation === 'string' ? m.expectation : '';
118
-
119
- const references = Array.isArray(m.references) ? m.references.slice() : [];
120
- const requirements =
121
- m.requirements === null ||
122
- typeof m.requirements === 'string' ||
123
- typeof m.requirements === 'object'
124
- ? m.requirements
125
- : null;
126
-
127
- const mappings =
128
- m.mappings === null || typeof m.mappings === 'string' || typeof m.mappings === 'object'
129
- ? m.mappings
130
- : null;
131
-
132
- if (i18n) {
133
- if (typeof i18n.titleKey !== 'string' || !i18n.titleKey.trim()) {
134
- throw new Error(`Rule ${ruleId}: meta.i18n.titleKey must be a non-empty string`);
135
- }
136
- if (
137
- i18n.descriptionKey != null &&
138
- (typeof i18n.descriptionKey !== 'string' || !i18n.descriptionKey.trim())
139
- ) {
140
- throw new Error(
141
- `Rule ${ruleId}: meta.i18n.descriptionKey must be a non-empty string when provided`
142
- );
143
- }
144
- }
145
-
146
- return {
147
- title,
148
- description,
149
- i18n,
150
- helpUrl,
151
- tags,
152
- wcagSc,
153
- normativeMappings,
154
- informativeReferences,
155
- defaultSeverity,
156
- defaultConfidence,
157
- type,
158
- coverage,
159
-
160
- ruleInterfaceVersion,
161
- ruleVersion,
162
- normative,
163
- atomic,
164
- deprecated,
165
- deprecation,
166
- category,
167
- standard,
168
- applicability,
169
- expectation,
170
- references,
171
- requirements,
172
- mappings
173
- };
174
- }
175
-
176
- module.exports = { normalizeRuleMeta };