@surea11y/core 1.4.1 → 1.5.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 (104) hide show
  1. package/CHANGELOG.md +47 -7
  2. package/README.md +19 -3
  3. package/docs/API_STABILITY.md +2 -2
  4. package/docs/ENGINE_OPTIONS.md +14 -10
  5. package/docs/I18N.md +176 -20
  6. package/docs/INTEGRATION.md +28 -6
  7. package/docs/LIMITATIONS.md +1 -1
  8. package/docs/OUTPUT_SCHEMA.md +13 -3
  9. package/docs/REPORT.md +2 -0
  10. package/docs/RULE_AUTHORING.md +53 -0
  11. package/docs/TROUBLESHOOTING.md +2 -2
  12. package/package.json +6 -1
  13. package/src/checks/automatic/aria-allowed-attr.js +27 -30
  14. package/src/checks/automatic/aria-allowed-role.js +14 -16
  15. package/src/checks/automatic/aria-braille-equivalent.js +17 -19
  16. package/src/checks/automatic/aria-conditional-attr.js +17 -19
  17. package/src/checks/automatic/aria-deprecated-role.js +62 -49
  18. package/src/checks/automatic/aria-hidden-body.js +2 -9
  19. package/src/checks/automatic/aria-hidden-focus.js +99 -18
  20. package/src/checks/automatic/aria-prohibited-attr.js +54 -55
  21. package/src/checks/automatic/aria-prohibited-children.js +26 -26
  22. package/src/checks/automatic/aria-required-attr.js +14 -17
  23. package/src/checks/automatic/aria-required-children.js +17 -20
  24. package/src/checks/automatic/aria-required-parent.js +17 -20
  25. package/src/checks/automatic/aria-roles-valid.js +37 -23
  26. package/src/checks/automatic/aria-valid-attr-value.js +18 -21
  27. package/src/checks/automatic/aria-valid-attr.js +14 -17
  28. package/src/checks/automatic/autocomplete-valid.js +15 -17
  29. package/src/checks/automatic/avoid-inline-spacing.js +14 -16
  30. package/src/checks/automatic/binary-control-name-present.js +19 -21
  31. package/src/checks/automatic/button-name-present.js +23 -28
  32. package/src/checks/automatic/combobox-name-present.js +15 -17
  33. package/src/checks/automatic/css-orientation-lock.js +22 -22
  34. package/src/checks/automatic/definition-list-children-valid.js +18 -21
  35. package/src/checks/automatic/deprecated-elements-not-used.js +14 -16
  36. package/src/checks/automatic/dialog-name-present.js +16 -18
  37. package/src/checks/automatic/dlitem-parent-valid.js +15 -17
  38. package/src/checks/automatic/duplicate-id-aria.js +45 -37
  39. package/src/checks/automatic/form-control-single-label.js +38 -40
  40. package/src/checks/automatic/html-xml-lang-mismatch.js +2 -9
  41. package/src/checks/automatic/iframe-focusable-content.js +29 -31
  42. package/src/checks/automatic/iframe-name-present.js +15 -17
  43. package/src/checks/automatic/iframe-title-unique.js +18 -23
  44. package/src/checks/automatic/label-in-name.js +31 -36
  45. package/src/checks/automatic/link-in-text-block.js +19 -21
  46. package/src/checks/automatic/link-name-present.js +25 -30
  47. package/src/checks/automatic/list-children-valid.js +15 -17
  48. package/src/checks/automatic/listbox-name-present.js +15 -17
  49. package/src/checks/automatic/listitem-parent-valid.js +14 -17
  50. package/src/checks/automatic/menuitem-name-present.js +16 -18
  51. package/src/checks/automatic/meta-refresh-no-exceptions.js +15 -18
  52. package/src/checks/automatic/meta-refresh-timing-absent.js +14 -17
  53. package/src/checks/automatic/meta-viewport-zoom-enabled.js +14 -17
  54. package/src/checks/automatic/meter-name-present.js +16 -18
  55. package/src/checks/automatic/nested-interactive-controls-absent.js +17 -19
  56. package/src/checks/automatic/option-name-present.js +16 -18
  57. package/src/checks/automatic/progressbar-name-present.js +19 -21
  58. package/src/checks/automatic/searchbox-name-present.js +19 -17
  59. package/src/checks/automatic/server-side-image-map-absent.js +15 -18
  60. package/src/checks/automatic/slider-name-present.js +15 -17
  61. package/src/checks/automatic/spinbutton-name-present.js +19 -17
  62. package/src/checks/automatic/summary-name-present.js +16 -18
  63. package/src/checks/automatic/tab-name-present.js +16 -18
  64. package/src/checks/automatic/table-headers-attr-valid.js +15 -17
  65. package/src/checks/automatic/table-th-has-data-cells.js +15 -19
  66. package/src/checks/automatic/target-size-minimum.js +104 -81
  67. package/src/checks/automatic/td-has-header.js +15 -20
  68. package/src/checks/automatic/textbox-name-present.js +15 -17
  69. package/src/checks/automatic/tooltip-name-present.js +16 -18
  70. package/src/checks/automatic/treeitem-name-present.js +16 -18
  71. package/src/checks/automatic/valid-lang.js +15 -17
  72. package/src/checks/manual/accesskeys-manual.js +18 -19
  73. package/src/checks/manual/aria-checked-state-mismatch-manual.js +19 -22
  74. package/src/checks/manual/bypass-blocks-present-manual.js +4 -12
  75. package/src/checks/manual/empty-heading-manual.js +15 -17
  76. package/src/checks/manual/empty-table-header-manual.js +27 -30
  77. package/src/checks/manual/form-control-programmatic-label-quality-manual.js +2 -9
  78. package/src/checks/manual/heading-order-manual.js +17 -22
  79. package/src/checks/manual/image-redundant-alt-manual.js +14 -17
  80. package/src/checks/manual/label-title-only-manual.js +15 -17
  81. package/src/checks/manual/landmark-banner-is-top-level-manual.js +14 -17
  82. package/src/checks/manual/landmark-contentinfo-is-top-level-manual.js +14 -17
  83. package/src/checks/manual/landmark-main-is-top-level-manual.js +14 -17
  84. package/src/checks/manual/landmark-no-duplicate-banner-manual.js +2 -7
  85. package/src/checks/manual/landmark-no-duplicate-contentinfo-manual.js +2 -7
  86. package/src/checks/manual/landmark-no-duplicate-main-manual.js +2 -7
  87. package/src/checks/manual/landmark-one-main-manual.js +2 -9
  88. package/src/checks/manual/landmark-unique-manual.js +22 -27
  89. package/src/checks/manual/link-name-quality-manual.js +15 -17
  90. package/src/checks/manual/meta-viewport-large-manual.js +14 -17
  91. package/src/checks/manual/mouse-only-event-handlers-manual.js +17 -19
  92. package/src/checks/manual/page-has-heading-one-manual.js +2 -9
  93. package/src/checks/manual/presentation-role-conflict-manual.js +19 -21
  94. package/src/checks/manual/region-manual.js +13 -6
  95. package/src/checks/manual/scope-attr-valid-manual.js +14 -17
  96. package/src/checks/manual/skip-link-manual.js +39 -47
  97. package/src/checks/manual/tabindex-manual.js +14 -17
  98. package/src/checks/manual/table-duplicate-name-manual.js +14 -17
  99. package/src/core.js +4203 -3604
  100. package/src/report.js +14 -0
  101. package/surea11y.browser.js +1960 -3671
  102. package/surea11y.i18n.de.js +22 -0
  103. package/surea11y.i18n.es.js +22 -0
  104. package/surea11y.i18n.fr.js +22 -0
@@ -117,30 +117,28 @@ function runInPage(ctx) {
117
117
  const hasKeyboardEquiv = KEYBOARD_EQUIV_ATTRS.some((a) => trim(el.getAttribute(a)));
118
118
  if (hasKeyboardEquiv) continue;
119
119
 
120
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
121
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
122
120
  const eligInfo = helpers.getEligibilityInfo
123
121
  ? helpers.getEligibilityInfo(el, ctx, { targetSet: 'acc' })
124
122
  : null;
125
123
 
126
- occurrences.push({
127
- selector: stableSelector,
128
- html,
129
- summary: `This element has ${presentMouseAttrs.join(', ')} but no keyboard-reachable equivalent handler.`,
130
- hint: 'Add onkeydown/onkeyup/onkeypress (or onfocus/onblur for hover-triggered behavior) so this functionality is also reachable by keyboard.',
131
- i18n: {
132
- summaryKey: 'mouseOnlyEventHandlers_summary_cantTell',
133
- hintKey: 'mouseOnlyEventHandlers_hint_cantTell',
134
- params: { attrs: presentMouseAttrs.join(', ') }
135
- },
136
- data: {
137
- details: {
138
- reasonCode: 'MOUSE_ONLY_HANDLER_NO_KEYBOARD_EQUIVALENT',
139
- mouseAttrs: presentMouseAttrs
124
+ occurrences.push(
125
+ helpers.reportOccurrence(el, {
126
+ summary: `This element has ${presentMouseAttrs.join(', ')} but no keyboard-reachable equivalent handler.`,
127
+ hint: 'Add onkeydown/onkeyup/onkeypress (or onfocus/onblur for hover-triggered behavior) so this functionality is also reachable by keyboard.',
128
+ i18n: {
129
+ summaryKey: 'mouseOnlyEventHandlers_summary_cantTell',
130
+ hintKey: 'mouseOnlyEventHandlers_hint_cantTell',
131
+ params: { attrs: presentMouseAttrs.join(', ') }
140
132
  },
141
- visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
142
- }
143
- });
133
+ data: {
134
+ details: {
135
+ reasonCode: 'MOUSE_ONLY_HANDLER_NO_KEYBOARD_EQUIVALENT',
136
+ mouseAttrs: presentMouseAttrs
137
+ },
138
+ visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
139
+ }
140
+ })
141
+ );
144
142
  }
145
143
 
146
144
  if (applicableCount === 0) {
@@ -126,19 +126,12 @@ function runInPage(ctx) {
126
126
  return { ruleId: rule.ruleId, outcome: 'notApplicable', severity: 'minor', occurrences: [] };
127
127
  }
128
128
 
129
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(body) : 'body';
130
- const html = helpers.getOuterHtmlSnippet
131
- ? helpers.getOuterHtmlSnippet(body)
132
- : (body.outerHTML || '').slice(0, 200);
133
-
134
129
  return {
135
130
  ruleId: rule.ruleId,
136
131
  outcome: 'cantTell',
137
132
  severity: rule.defaultSeverity || 'minor',
138
133
  occurrences: [
139
- {
140
- selector: stableSelector,
141
- html,
134
+ helpers.reportOccurrence(body, {
142
135
  summary: 'This page has no level-one heading.',
143
136
  hint: 'Add a level-one heading (<h1> or role="heading" aria-level="1") that identifies the page\'s main content.',
144
137
  i18n: {
@@ -149,7 +142,7 @@ function runInPage(ctx) {
149
142
  data: {
150
143
  details: { reasonCode: 'HEADING_ONE_MISSING' }
151
144
  }
152
- }
145
+ })
153
146
  ]
154
147
  };
155
148
  }
@@ -171,28 +171,26 @@ function runInPage(ctx) {
171
171
  String(el.getAttribute('role') || '')
172
172
  .trim()
173
173
  .toLowerCase() || 'presentation';
174
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
175
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
176
-
177
- occurrences.push({
178
- selector: stableSelector,
179
- html,
180
- summary: `This role="${role}" element also has a conflicting condition (${parts.join(', ')}), which restores its implicit role and cancels the presentational intent.`,
181
- hint: 'Remove the conflicting naming attribute(s) and/or focusability (tabindex/native) if the element should stay presentational, or remove role="presentation"/"none" if it should be exposed to assistive technology.',
182
- i18n: {
183
- summaryKey: 'presentationRoleConflict_summary_cantTell',
184
- hintKey: 'presentationRoleConflict_hint_cantTell',
185
- params: { role, attrs: parts.join(', ') }
186
- },
187
- data: {
188
- details: {
189
- reasonCode: 'PRESENTATION_ROLE_CONFLICT',
190
- role,
191
- conflictingAttrs: present,
192
- focusable: isFocusable
174
+
175
+ occurrences.push(
176
+ helpers.reportOccurrence(el, {
177
+ summary: `This role="${role}" element also has a conflicting condition (${parts.join(', ')}), which restores its implicit role and cancels the presentational intent.`,
178
+ hint: 'Remove the conflicting naming attribute(s) and/or focusability (tabindex/native) if the element should stay presentational, or remove role="presentation"/"none" if it should be exposed to assistive technology.',
179
+ i18n: {
180
+ summaryKey: 'presentationRoleConflict_summary_cantTell',
181
+ hintKey: 'presentationRoleConflict_hint_cantTell',
182
+ params: { role, attrs: parts.join(', ') }
183
+ },
184
+ data: {
185
+ details: {
186
+ reasonCode: 'PRESENTATION_ROLE_CONFLICT',
187
+ role,
188
+ conflictingAttrs: present,
189
+ focusable: isFocusable
190
+ }
193
191
  }
194
- }
195
- });
192
+ })
193
+ );
196
194
  }
197
195
 
198
196
  if (applicableCount === 0) {
@@ -352,14 +352,11 @@ function runInPage(ctx) {
352
352
  }
353
353
  }
354
354
 
355
+ // Report the element itself: without a node reference the engine re-finds
356
+ // each one with document.querySelector to build its structuralPath.
355
357
  const occurrences = collapsed.map((el) => {
356
358
  const tag = el.tagName ? lower(el.tagName) : '';
357
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
358
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
359
-
360
- return {
361
- selector: stableSelector,
362
- html,
359
+ const partial = {
363
360
  summary: 'This content is not contained within a landmark region.',
364
361
  hint: 'Move this content inside a landmark region (main, nav, aside, a labeled section, etc.).',
365
362
  i18n: {
@@ -371,6 +368,16 @@ function runInPage(ctx) {
371
368
  details: { reasonCode: 'CONTENT_OUTSIDE_LANDMARK', element: tag }
372
369
  }
373
370
  };
371
+
372
+ if (helpers && typeof helpers.reportOccurrence === 'function') {
373
+ return helpers.reportOccurrence(el, partial);
374
+ }
375
+
376
+ return {
377
+ selector: helpers.buildSelector ? helpers.buildSelector(el) : 'html',
378
+ html: helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '',
379
+ ...partial
380
+ };
374
381
  });
375
382
 
376
383
  if (occurrences.length === 0) {
@@ -61,23 +61,20 @@ function runInPage(ctx) {
61
61
 
62
62
  if (VALID_SCOPES.has(raw.toLowerCase())) continue;
63
63
 
64
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
65
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
66
-
67
- occurrences.push({
68
- selector: stableSelector,
69
- html,
70
- summary: 'This scope attribute value is not recognized.',
71
- hint: 'Use one of row, col, rowgroup, or colgroup for the scope attribute.',
72
- i18n: {
73
- summaryKey: 'scopeAttrValid_summary_cantTell',
74
- hintKey: 'scopeAttrValid_hint_cantTell',
75
- params: { value: raw }
76
- },
77
- data: {
78
- details: { reasonCode: 'SCOPE_ATTR_INVALID', value: raw }
79
- }
80
- });
64
+ occurrences.push(
65
+ helpers.reportOccurrence(el, {
66
+ summary: 'This scope attribute value is not recognized.',
67
+ hint: 'Use one of row, col, rowgroup, or colgroup for the scope attribute.',
68
+ i18n: {
69
+ summaryKey: 'scopeAttrValid_summary_cantTell',
70
+ hintKey: 'scopeAttrValid_hint_cantTell',
71
+ params: { value: raw }
72
+ },
73
+ data: {
74
+ details: { reasonCode: 'SCOPE_ATTR_INVALID', value: raw }
75
+ }
76
+ })
77
+ );
81
78
  }
82
79
 
83
80
  if (applicableCount === 0) {
@@ -184,59 +184,51 @@ function runInPage(ctx) {
184
184
  const unusableByGeometry = !!geometryReasonCode;
185
185
  if (!unusableByAcc && !unusableByGeometry) continue;
186
186
 
187
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
188
- const html = helpers.getOuterHtmlSnippet
189
- ? helpers.getOuterHtmlSnippet(el)
190
- : el.outerHTML || '';
187
+ occurrences.push(
188
+ helpers.reportOccurrence(el, {
189
+ summary: 'This skip link points to a target that exists but is not currently usable.',
190
+ hint: 'Point this skip link to a target that is exposed and usable as a navigation destination.',
191
+ i18n: {
192
+ summaryKey: 'skipLink_summary_unusableTarget_cantTell',
193
+ hintKey: 'skipLink_hint_unusableTarget_cantTell',
194
+ params: { href }
195
+ },
196
+ data: {
197
+ details: {
198
+ reasonCode: 'SKIP_LINK_TARGET_UNUSABLE',
199
+ href,
200
+ unusableReasonCode: unusableByAcc ? 'ACC_TREE_INELIGIBLE' : geometryReasonCode,
201
+ targetSelector: helpers.buildSelector ? helpers.buildSelector(target) : null,
202
+ geometryCheckEnabled: geometrySupported
203
+ },
204
+ visibilityFilter: {
205
+ targetSet: 'acc',
206
+ accEligible: accEligibility.eligible,
207
+ reasons: accEligibility.reasons
208
+ },
209
+ targetGeometry: geometryEligibility
210
+ ? { eligible: geometryEligibility.eligible, reasons: geometryEligibility.reasons }
211
+ : { eligible: null, reasons: [] }
212
+ }
213
+ })
214
+ );
215
+ continue;
216
+ }
191
217
 
192
- occurrences.push({
193
- selector: stableSelector,
194
- html,
195
- summary: 'This skip link points to a target that exists but is not currently usable.',
196
- hint: 'Point this skip link to a target that is exposed and usable as a navigation destination.',
218
+ occurrences.push(
219
+ helpers.reportOccurrence(el, {
220
+ summary: "This skip link's target does not exist.",
221
+ hint: "Point the skip link's href at an id that exists in the document, or add the missing target element.",
197
222
  i18n: {
198
- summaryKey: 'skipLink_summary_unusableTarget_cantTell',
199
- hintKey: 'skipLink_hint_unusableTarget_cantTell',
223
+ summaryKey: 'skipLink_summary_cantTell',
224
+ hintKey: 'skipLink_hint_cantTell',
200
225
  params: { href }
201
226
  },
202
227
  data: {
203
- details: {
204
- reasonCode: 'SKIP_LINK_TARGET_UNUSABLE',
205
- href,
206
- unusableReasonCode: unusableByAcc ? 'ACC_TREE_INELIGIBLE' : geometryReasonCode,
207
- targetSelector: helpers.buildSelector ? helpers.buildSelector(target) : null,
208
- geometryCheckEnabled: geometrySupported
209
- },
210
- visibilityFilter: {
211
- targetSet: 'acc',
212
- accEligible: accEligibility.eligible,
213
- reasons: accEligibility.reasons
214
- },
215
- targetGeometry: geometryEligibility
216
- ? { eligible: geometryEligibility.eligible, reasons: geometryEligibility.reasons }
217
- : { eligible: null, reasons: [] }
228
+ details: { reasonCode: 'SKIP_LINK_TARGET_MISSING', href }
218
229
  }
219
- });
220
- continue;
221
- }
222
-
223
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
224
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
225
-
226
- occurrences.push({
227
- selector: stableSelector,
228
- html,
229
- summary: "This skip link's target does not exist.",
230
- hint: "Point the skip link's href at an id that exists in the document, or add the missing target element.",
231
- i18n: {
232
- summaryKey: 'skipLink_summary_cantTell',
233
- hintKey: 'skipLink_hint_cantTell',
234
- params: { href }
235
- },
236
- data: {
237
- details: { reasonCode: 'SKIP_LINK_TARGET_MISSING', href }
238
- }
239
- });
230
+ })
231
+ );
240
232
  }
241
233
 
242
234
  if (applicableCount === 0) {
@@ -62,23 +62,20 @@ function runInPage(ctx) {
62
62
 
63
63
  if (n <= 0) continue;
64
64
 
65
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
66
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
67
-
68
- occurrences.push({
69
- selector: stableSelector,
70
- html,
71
- summary: 'This element has a positive tabindex, overriding the natural tab order.',
72
- hint: 'Use tabindex="0" (or a negative value to remove from tab order) instead of a positive number; fix the DOM order if a different tab order is needed.',
73
- i18n: {
74
- summaryKey: 'tabindex_summary_cantTell',
75
- hintKey: 'tabindex_hint_cantTell',
76
- params: { value: String(n) }
77
- },
78
- data: {
79
- details: { reasonCode: 'TABINDEX_POSITIVE', value: n }
80
- }
81
- });
65
+ occurrences.push(
66
+ helpers.reportOccurrence(el, {
67
+ summary: 'This element has a positive tabindex, overriding the natural tab order.',
68
+ hint: 'Use tabindex="0" (or a negative value to remove from tab order) instead of a positive number; fix the DOM order if a different tab order is needed.',
69
+ i18n: {
70
+ summaryKey: 'tabindex_summary_cantTell',
71
+ hintKey: 'tabindex_hint_cantTell',
72
+ params: { value: String(n) }
73
+ },
74
+ data: {
75
+ details: { reasonCode: 'TABINDEX_POSITIVE', value: n }
76
+ }
77
+ })
78
+ );
82
79
  }
83
80
 
84
81
  if (applicableCount === 0) {
@@ -73,23 +73,20 @@ function runInPage(ctx) {
73
73
 
74
74
  if (captionText.toLowerCase() !== summary.toLowerCase()) continue;
75
75
 
76
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
77
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
78
-
79
- occurrences.push({
80
- selector: stableSelector,
81
- html,
82
- summary: "This table's caption duplicates its summary attribute.",
83
- hint: 'Remove the redundant summary attribute, or make it provide different information than the caption.',
84
- i18n: {
85
- summaryKey: 'tableDuplicateName_summary_cantTell',
86
- hintKey: 'tableDuplicateName_hint_cantTell',
87
- params: {}
88
- },
89
- data: {
90
- details: { reasonCode: 'TABLE_CAPTION_SUMMARY_DUPLICATE' }
91
- }
92
- });
76
+ occurrences.push(
77
+ helpers.reportOccurrence(el, {
78
+ summary: "This table's caption duplicates its summary attribute.",
79
+ hint: 'Remove the redundant summary attribute, or make it provide different information than the caption.',
80
+ i18n: {
81
+ summaryKey: 'tableDuplicateName_summary_cantTell',
82
+ hintKey: 'tableDuplicateName_hint_cantTell',
83
+ params: {}
84
+ },
85
+ data: {
86
+ details: { reasonCode: 'TABLE_CAPTION_SUMMARY_DUPLICATE' }
87
+ }
88
+ })
89
+ );
93
90
  }
94
91
 
95
92
  if (applicableCount === 0) {