@surea11y/core 1.3.0 → 1.4.1

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 (166) hide show
  1. package/CHANGELOG.md +87 -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/ARIA_DEPRECATION.md +95 -0
  6. package/docs/CI_INTEGRATIONS.md +7 -7
  7. package/docs/ENGINE_OPTIONS.md +1 -1
  8. package/docs/I18N.md +12 -9
  9. package/docs/INTEGRATION.md +1 -1
  10. package/docs/LIMITATIONS.md +1 -1
  11. package/docs/REPORT.md +1 -1
  12. package/docs/RULE_CATALOG.md +6 -6
  13. package/package.json +52 -16
  14. package/src/baseline.js +0 -0
  15. package/src/checks/automatic/area-alt-present.js +4 -6
  16. package/src/checks/automatic/aria-allowed-attr.js +663 -134
  17. package/src/checks/automatic/aria-allowed-role.js +2 -0
  18. package/src/checks/automatic/aria-braille-equivalent.js +2 -0
  19. package/src/checks/automatic/aria-conditional-attr.js +8 -7
  20. package/src/checks/automatic/aria-deprecated-role.js +107 -38
  21. package/src/checks/automatic/aria-hidden-body.js +6 -4
  22. package/src/checks/automatic/aria-hidden-focus.js +12 -13
  23. package/src/checks/automatic/aria-prohibited-attr.js +98 -105
  24. package/src/checks/automatic/aria-prohibited-children.js +56 -87
  25. package/src/checks/automatic/aria-required-attr.js +6 -7
  26. package/src/checks/automatic/aria-required-children.js +7 -10
  27. package/src/checks/automatic/aria-required-parent.js +20 -25
  28. package/src/checks/automatic/aria-role-name-present.js +2 -0
  29. package/src/checks/automatic/aria-roles-valid.js +33 -6
  30. package/src/checks/automatic/aria-valid-attr-value.js +18 -15
  31. package/src/checks/automatic/aria-valid-attr.js +2 -0
  32. package/src/checks/automatic/autocomplete-valid.js +39 -1
  33. package/src/checks/automatic/avoid-inline-spacing.js +181 -20
  34. package/src/checks/automatic/binary-control-name-present.js +13 -3
  35. package/src/checks/automatic/button-name-present.js +54 -21
  36. package/src/checks/automatic/canvas-text-alternative-present.js +17 -8
  37. package/src/checks/automatic/combobox-name-present.js +10 -1
  38. package/src/checks/automatic/contrast-computable.js +2 -0
  39. package/src/checks/automatic/contrast-enhanced.js +2 -0
  40. package/src/checks/automatic/contrast-minimum.js +2 -0
  41. package/src/checks/automatic/css-orientation-lock.js +21 -27
  42. package/src/checks/automatic/definition-list-children-valid.js +6 -6
  43. package/src/checks/automatic/deprecated-elements-not-used.js +4 -2
  44. package/src/checks/automatic/dialog-name-present.js +18 -11
  45. package/src/checks/automatic/dlitem-parent-valid.js +2 -0
  46. package/src/checks/automatic/duplicate-id-aria.js +4 -3
  47. package/src/checks/automatic/embed-text-alternative-present.js +2 -0
  48. package/src/checks/automatic/form-control-programmatic-label-present.js +50 -4
  49. package/src/checks/automatic/form-control-single-label.js +110 -43
  50. package/src/checks/automatic/html-xml-lang-mismatch.js +2 -0
  51. package/src/checks/automatic/iframe-focusable-content.js +246 -18
  52. package/src/checks/automatic/iframe-name-present.js +2 -0
  53. package/src/checks/automatic/iframe-title-unique.js +3 -1
  54. package/src/checks/automatic/img-alt-present.js +23 -18
  55. package/src/checks/automatic/input-image-alt-present.js +101 -52
  56. package/src/checks/automatic/label-in-name.js +97 -27
  57. package/src/checks/automatic/language-page-present.js +7 -1
  58. package/src/checks/automatic/link-in-text-block.js +2 -0
  59. package/src/checks/automatic/link-name-present.js +52 -17
  60. package/src/checks/automatic/list-children-valid.js +14 -24
  61. package/src/checks/automatic/listbox-name-present.js +10 -1
  62. package/src/checks/automatic/listitem-parent-valid.js +30 -7
  63. package/src/checks/automatic/menuitem-name-present.js +10 -1
  64. package/src/checks/automatic/meta-refresh-no-exceptions.js +33 -4
  65. package/src/checks/automatic/meta-refresh-timing-absent.js +32 -4
  66. package/src/checks/automatic/meta-viewport-zoom-enabled.js +39 -15
  67. package/src/checks/automatic/meter-name-present.js +12 -4
  68. package/src/checks/automatic/nested-interactive-controls-absent.js +177 -25
  69. package/src/checks/automatic/object-text-alternative-present.js +16 -7
  70. package/src/checks/automatic/option-name-present.js +10 -1
  71. package/src/checks/automatic/page-title-present.js +2 -0
  72. package/src/checks/automatic/progressbar-name-present.js +16 -11
  73. package/src/checks/automatic/role-img-alt-present.js +4 -4
  74. package/src/checks/automatic/searchbox-name-present.js +10 -1
  75. package/src/checks/automatic/server-side-image-map-absent.js +4 -3
  76. package/src/checks/automatic/slider-name-present.js +13 -2
  77. package/src/checks/automatic/spinbutton-name-present.js +10 -1
  78. package/src/checks/automatic/summary-name-present.js +10 -1
  79. package/src/checks/automatic/svg-image-text-alternative-present.js +2 -0
  80. package/src/checks/automatic/svg-text-alternative-present.js +17 -5
  81. package/src/checks/automatic/tab-name-present.js +10 -1
  82. package/src/checks/automatic/table-headers-attr-valid.js +3 -2
  83. package/src/checks/automatic/table-th-has-data-cells.js +69 -6
  84. package/src/checks/automatic/target-size-minimum.js +5 -0
  85. package/src/checks/automatic/td-has-header.js +24 -1
  86. package/src/checks/automatic/textbox-name-present.js +10 -1
  87. package/src/checks/automatic/tooltip-name-present.js +10 -1
  88. package/src/checks/automatic/treeitem-name-present.js +10 -1
  89. package/src/checks/automatic/valid-lang.js +18 -3
  90. package/src/checks/automatic/video-poster-text-alternative-present.js +2 -0
  91. package/src/checks/manual/accesskeys-manual.js +3 -1
  92. package/src/checks/manual/area-alt-decorative-manual.js +2 -0
  93. package/src/checks/manual/area-alt-quality-manual.js +2 -0
  94. package/src/checks/manual/aria-checked-state-mismatch-manual.js +14 -23
  95. package/src/checks/manual/aria-text-manual.js +6 -5
  96. package/src/checks/manual/bypass-blocks-present-manual.js +279 -0
  97. package/src/checks/manual/canvas-text-alternative-quality-manual.js +2 -0
  98. package/src/checks/manual/css-hidden-focus.js +184 -9
  99. package/src/checks/manual/embed-text-alternative-quality-manual.js +18 -13
  100. package/src/checks/manual/empty-heading-manual.js +17 -17
  101. package/src/checks/manual/empty-table-header-manual.js +52 -25
  102. package/src/checks/manual/focus-order-semantics-manual.js +16 -4
  103. package/src/checks/manual/form-control-programmatic-label-quality-manual.js +2 -0
  104. package/src/checks/manual/heading-order-manual.js +28 -1
  105. package/src/checks/manual/identical-links-same-purpose-manual.js +2 -0
  106. package/src/checks/manual/image-redundant-alt-manual.js +21 -1
  107. package/src/checks/manual/img-alt-decorative-manual.js +2 -0
  108. package/src/checks/manual/img-alt-quality-manual.js +2 -0
  109. package/src/checks/manual/input-image-alt-decorative-manual.js +26 -0
  110. package/src/checks/manual/input-image-alt-quality-manual.js +2 -0
  111. package/src/checks/manual/label-title-only-manual.js +29 -22
  112. package/src/checks/manual/landmark-banner-is-top-level-manual.js +51 -55
  113. package/src/checks/manual/landmark-contentinfo-is-top-level-manual.js +44 -31
  114. package/src/checks/manual/landmark-main-is-top-level-manual.js +41 -24
  115. package/src/checks/manual/landmark-no-duplicate-banner-manual.js +16 -23
  116. package/src/checks/manual/landmark-no-duplicate-contentinfo-manual.js +14 -21
  117. package/src/checks/manual/landmark-no-duplicate-main-manual.js +10 -13
  118. package/src/checks/manual/landmark-one-main-manual.js +12 -23
  119. package/src/checks/manual/landmark-unique-manual.js +37 -52
  120. package/src/checks/manual/link-name-quality-manual.js +2 -0
  121. package/src/checks/manual/media-transcript-present-manual.js +2 -0
  122. package/src/checks/manual/meta-viewport-large-manual.js +3 -1
  123. package/src/checks/manual/mouse-only-event-handlers-manual.js +2 -0
  124. package/src/checks/manual/no-autoplay-audio-manual.js +2 -0
  125. package/src/checks/manual/object-text-alternative-quality-manual.js +2 -0
  126. package/src/checks/manual/p-as-heading-manual.js +2 -0
  127. package/src/checks/manual/page-has-heading-one-manual.js +12 -11
  128. package/src/checks/manual/page-title-patterns-manual.js +2 -0
  129. package/src/checks/manual/presentation-role-conflict-manual.js +51 -37
  130. package/src/checks/manual/region-manual.js +27 -36
  131. package/src/checks/manual/scope-attr-valid-manual.js +3 -1
  132. package/src/checks/manual/scrollable-region-focusable-manual.js +2 -0
  133. package/src/checks/manual/skip-link-manual.js +7 -6
  134. package/src/checks/manual/svg-text-alternative-quality-manual.js +2 -0
  135. package/src/checks/manual/tabindex-manual.js +3 -1
  136. package/src/checks/manual/table-duplicate-name-manual.js +5 -4
  137. package/src/checks/manual/table-fake-caption-manual.js +24 -3
  138. package/src/checks/manual/video-caption-manual.js +2 -0
  139. package/src/checks/manual-review.js +2 -0
  140. package/src/core.js +11820 -3317
  141. package/src/index.js +2 -0
  142. package/src/report.js +51 -9
  143. package/src/sarif.js +20 -5
  144. package/surea11y.browser.js +4943 -1388
  145. package/bin/core.js +0 -473
  146. package/docs/CLI.md +0 -128
  147. package/src/catalogs/composites.wcag.js +0 -454
  148. package/src/checks/automatic/bypass-blocks-present.js +0 -215
  149. package/src/checks/rules-and-tags.full.csv +0 -19
  150. package/src/checks/rules-and-tags.full.json +0 -259
  151. package/src/core/aria-helpers.js +0 -1211
  152. package/src/core/contrast-helpers.js +0 -1302
  153. package/src/core/dom-helpers.js +0 -4493
  154. package/src/core/dom-runner.js +0 -787
  155. package/src/core/frame-messaging.js +0 -261
  156. package/src/core/frame-scan.js +0 -190
  157. package/src/core/rollup-composites.js +0 -127
  158. package/src/core/rule-meta.js +0 -176
  159. package/src/coverage/wcag-facets.js +0 -1079
  160. package/src/coverage/wcag-version-map.js +0 -84
  161. package/src/i18n/en.js +0 -1228
  162. package/src/i18n/fr.js +0 -1185
  163. package/src/policy/contracts.js +0 -18
  164. package/src/policy/resolvePolicy.js +0 -59
  165. package/src/policy/schemas/engine-options.schema.json +0 -103
  166. package/src/policy/schemas/policy-contract.schema.json +0 -40
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- POLICY_CONTRACTS: {
5
- a11y: {
6
- id: 'a11y',
7
- allowedOutcomes: ['fail', 'pass', 'cantTell', 'notApplicable'],
8
- allowedConfidence: ['high', 'medium', 'low'],
9
- coerceManualFailToCantTell: true
10
- },
11
- generic: {
12
- id: 'generic',
13
- allowedOutcomes: ['fail', 'pass', 'cantTell', 'notApplicable'],
14
- allowedConfidence: ['high', 'medium', 'low'],
15
- coerceManualFailToCantTell: false
16
- }
17
- }
18
- };
@@ -1,59 +0,0 @@
1
- 'use strict';
2
-
3
- function resolvePolicy(POLICY_CONTRACTS, engineOptions) {
4
- function normalizePolicyContract(POLICY_CONTRACTS, contract, fallbackId) {
5
- const fallback = POLICY_CONTRACTS[fallbackId] || POLICY_CONTRACTS.a11y;
6
- if (typeof contract === 'string') return POLICY_CONTRACTS[contract] || fallback;
7
-
8
- if (contract && typeof contract === 'object') {
9
- const allowedOutcomes = Array.isArray(contract.allowedOutcomes)
10
- ? contract.allowedOutcomes.slice()
11
- : fallback.allowedOutcomes.slice();
12
-
13
- const allowedConfidence = Array.isArray(contract.allowedConfidence)
14
- ? contract.allowedConfidence.slice()
15
- : fallback.allowedConfidence.slice();
16
-
17
- return {
18
- id:
19
- typeof contract.id === 'string' && contract.id.trim()
20
- ? contract.id.trim()
21
- : fallback.id || fallbackId || 'custom',
22
- allowedOutcomes,
23
- allowedConfidence,
24
- coerceManualFailToCantTell:
25
- typeof contract.coerceManualFailToCantTell === 'boolean'
26
- ? contract.coerceManualFailToCantTell
27
- : !!fallback.coerceManualFailToCantTell
28
- };
29
- }
30
-
31
- return fallback;
32
- }
33
-
34
- function normalizePolicyOverrides(policy) {
35
- const p = policy && typeof policy === 'object' ? policy : {};
36
- return {
37
- allowedOutcomes: Array.isArray(p.allowedOutcomes) ? p.allowedOutcomes.slice() : null,
38
- allowedConfidence: Array.isArray(p.allowedConfidence) ? p.allowedConfidence.slice() : null,
39
- coerceManualFailToCantTell:
40
- typeof p.coerceManualFailToCantTell === 'boolean' ? p.coerceManualFailToCantTell : null
41
- };
42
- }
43
-
44
- const opts = engineOptions && typeof engineOptions === 'object' ? engineOptions : {};
45
- const contract = normalizePolicyContract(POLICY_CONTRACTS, opts.policyContract, 'a11y');
46
- const ov = normalizePolicyOverrides(opts.policy);
47
-
48
- return {
49
- contractId: contract.id,
50
- allowedOutcomes: ov.allowedOutcomes || contract.allowedOutcomes.slice(),
51
- allowedConfidence: ov.allowedConfidence || contract.allowedConfidence.slice(),
52
- coerceManualFailToCantTell:
53
- ov.coerceManualFailToCantTell !== null
54
- ? ov.coerceManualFailToCantTell
55
- : !!contract.coerceManualFailToCantTell
56
- };
57
- }
58
-
59
- module.exports = { resolvePolicy };
@@ -1,103 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://a11ycore.dev/schemas/engine-options.schema.json",
4
- "title": "EngineOptions",
5
- "description": "Top-level configuration object for the engine runtime (v1).",
6
- "type": "object",
7
- "additionalProperties": true,
8
- "properties": {
9
- "locale": {
10
- "type": "string",
11
- "minLength": 1,
12
- "description": "Requested locale for i18n resolution (fallback to 'en' if missing)."
13
- },
14
- "includeShadowDom": {
15
- "type": "boolean",
16
- "description": "When true, queries traverse open shadow roots via helpers.queryAllSmart."
17
- },
18
- "excludeSelectors": {
19
- "description": "CSS selector(s) that define subtrees to exclude from scanning.",
20
- "oneOf": [
21
- { "type": "string", "minLength": 1 },
22
- { "type": "array", "items": { "type": "string", "minLength": 1 } }
23
- ]
24
- },
25
-
26
- "contrast": {
27
- "type": "object",
28
- "additionalProperties": false,
29
- "description": "Options that control contrast-related computations and assumptions.",
30
- "properties": {
31
- "mode": {
32
- "type": "string",
33
- "enum": ["strictConformance", "auditorAssist"],
34
- "default": "strictConformance",
35
- "description": "Controls whether the engine may apply explicit assumptions to reduce cantTell for contrast checks."
36
- },
37
- "rootCanvasFallback": {
38
- "type": "string",
39
- "minLength": 1,
40
- "default": "#ffffff",
41
- "description": "Used only when the effective root/canvas background is not computable and contrast.mode allows assumptions."
42
- }
43
- }
44
- },
45
-
46
- "rules": {
47
- "type": "object",
48
- "description": "Per-rule configuration. Keys are canonical ruleIds (e.g. 'img-alt-attr-present').",
49
- "additionalProperties": {
50
- "type": "object",
51
- "additionalProperties": true
52
- }
53
- },
54
- "policyContract": {
55
- "oneOf": [
56
- { "type": "string", "minLength": 1 },
57
- { "$ref": "policy-contract.schema.json" }
58
- ],
59
- "description": "Policy contract identifier or inline policy contract object."
60
- },
61
- "policy": {
62
- "type": "object",
63
- "additionalProperties": false,
64
- "properties": {
65
- "allowedOutcomes": {
66
- "type": ["array", "null"],
67
- "uniqueItems": true,
68
- "items": {
69
- "type": "string",
70
- "enum": ["fail", "pass", "cantTell", "notApplicable"]
71
- }
72
- },
73
- "allowedConfidence": {
74
- "type": ["array", "null"],
75
- "uniqueItems": true,
76
- "items": {
77
- "type": "string",
78
- "enum": ["high", "medium", "low"]
79
- }
80
- },
81
- "coerceManualFailToCantTell": {
82
- "type": ["boolean", "null"]
83
- }
84
- },
85
- "description": "Optional policy overrides applied on top of the resolved policy contract."
86
- },
87
- "output": {
88
- "type": "object",
89
- "additionalProperties": false,
90
- "properties": {
91
- "includeSelector": {
92
- "type": ["boolean", "null"],
93
- "description": "When false, the engine will not populate occurrence.selector (kept as empty string)."
94
- },
95
- "includeHtml": {
96
- "type": ["boolean", "null"],
97
- "description": "When false, the engine will not populate occurrence.html (kept as empty string)."
98
- }
99
- },
100
- "description": "Output shaping options for reporting/performance."
101
- }
102
- }
103
- }
@@ -1,40 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://a11ycore.dev/schemas/policy-contract.schema.json",
4
- "title": "PolicyContract",
5
- "description": "Defines the enforcement policy for rule outcomes and confidence handling (v1).",
6
- "type": "object",
7
- "additionalProperties": false,
8
- "properties": {
9
- "id": {
10
- "type": "string",
11
- "minLength": 1,
12
- "description": "Identifier for the policy contract."
13
- },
14
- "allowedOutcomes": {
15
- "type": "array",
16
- "minItems": 1,
17
- "uniqueItems": true,
18
- "items": {
19
- "type": "string",
20
- "enum": ["fail", "pass", "cantTell", "notApplicable"]
21
- },
22
- "description": "Allowed normalized outcomes for rules."
23
- },
24
- "allowedConfidence": {
25
- "type": "array",
26
- "minItems": 1,
27
- "uniqueItems": true,
28
- "items": {
29
- "type": "string",
30
- "enum": ["high", "medium", "low"]
31
- },
32
- "description": "Allowed confidence levels for rule results."
33
- },
34
- "coerceManualFailToCantTell": {
35
- "type": "boolean",
36
- "description": "Whether manual rules are prevented from producing a fail outcome (coerced to cantTell)."
37
- }
38
- },
39
- "required": ["id", "allowedOutcomes", "allowedConfidence", "coerceManualFailToCantTell"]
40
- }