JS-2013 Align S6842 with the ARIA in HTML conformance table#7484
JS-2013 Align S6842 with the ARIA in HTML conformance table#7484erwan-leforestier-sonarsource wants to merge 6 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
4a8f2d7 to
3e622bd
Compare
Extend beyond the composite-widget overrides to the full conformance table by decorating the jsx-a11y rule. config.ts keeps the flat, spec-derived allowlists; decorator.ts handles what the allowlist cannot express: - elements that accept any role (table family, text-level elements); - context-sensitive elements: li (parent list role), img (accessible name), figure (figcaption), label (association); - toolbar treated as a structure role (non-interactive), matching sonar-html. Fixes the previous false positives (nav, headings, named img, any-role elements) and the treegrid-on-ul/ol false negative, and drops the incorrect table[role=button] true positives so both analyzers agree with the spec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Review 👍 Approved with suggestions 1 resolved / 3 findingsAligns S6842 with the ARIA in HTML conformance table using a new decorator to handle context-sensitive roles. Address the minor limitations regarding non-literal accessible names and global 💡 Edge Case: img name/role check ignores non-literal attribute values📄 packages/analysis/src/jsts/rules/S6842/decorator.ts:149 📄 packages/analysis/src/jsts/rules/S6842/decorator.ts:177-188 📄 packages/analysis/src/jsts/rules/S6842/decorator.ts:201-215 In 💡 Edge Case: toolbar role suppressed globally before context checks📄 packages/analysis/src/jsts/rules/S6842/decorator.ts:138-141 📄 packages/analysis/src/jsts/rules/S6842/decorator.ts:145-156
✅ 1 resolved✅ Quality: deepStrictEqual test is brittle to upstream jsx-a11y changes
🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Code Review ✅ Approved 3 resolved / 3 findingsAligns S6842 with the full ARIA in HTML conformance table by separating static allowlists from complex contextual decorations. Consider updating the ✅ 3 resolved✅ Quality: deepStrictEqual test is brittle to upstream jsx-a11y changes
✅ Edge Case: toolbar role suppressed globally before context checks
✅ Edge Case: img name/role check ignores non-literal attribute values
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Summary
Align
S6842with the full ARIA in HTML conformance table, not only the composite-widget overrides. jsx-a11y's element→roles allowlist cannot express context, so the rule is now decorated:config.tskeeps the flat, spec-derived allowlists anddecorator.tshandles everything the allowlist cannot. This brings the JS/TS analyzer to parity with the sonar-html implementation (SONARHTML-403) — both now agree with the spec on every element/role pair.Changes
config.ts: enumerated allowlists per the conformance table —ul/ol/menu(droptreegrid),nav,h1–h6,fieldset,td,progress;liis left to the decorator.decorator.ts(new): suppresses the combinations the table permits but the allowlist cannot describe:table/tbody/thead/tfoot, text-level elements such asp,blockquote,time,output, …);li(only restricted when a parent exposes alistrole),img(interactive roles allowed only with an accessible name),figure(restricted only with afigcaption),label(restricted only when associated with a control);toolbartreated as a structure role (non-interactive), consistent with sonar-html and the WAI-ARIA role taxonomy.Fixes vs. the previous revision
nav, headings, namedimg, and any-role elements.treegrid-on-ul/olreport (spec forbids it).table[role="button"]/tbody[role="button"]true positives — the table family accepts any role.Tests
unit.test.tsrewritten as a spec matrix (valid + invalid) covering every case above.