mcpField
S
scan-code-accessibility-figma

scan-code-accessibility-figma

github.com/southleftTesting & quality2068 installsUpdated 21w ago
Repository

About scan-code-accessibility-figma

scan-code-accessibility-figma scans HTML with axe-core in JSDOM for structural and semantic accessibility issues. It is for Figma-to-code workflows and can emit accessibility data for design-parity checks; visual rules are excluded because JSDOM has no layout engine.

Key features

  1. 01Scan HTML with axe-core
  2. 02Filter by WCAG tags
  3. 03Limit scans to a CSS selector
  4. 04Report violations as JSON
  5. 05Emit codeSpec accessibility data

Use cases

  1. 01Check accessibility in generated component HTML
  2. 02Find missing labels, roles, or alt text
  3. 03Scope checks to one component
  4. 04Prepare accessibility data for parity checks

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/southleft/skills-for-figma --skill scan-code-accessibility-figma

After installing, type/scan-code-accessibility-figmain Claude Code to confirm it loaded.

Bundled filesscripts/package.jsonscripts/scan.mjs

Details

From the project README

scan-code-accessibility-figma — axe-core + JSDOM scan of HTML

Run axe-core (Deque's accessibility engine) against an HTML string using JSDOM. This is the code side of the accessibility story: it checks the markup your Figma-to-code workflow produced. It pairs with lint-design-figma (design side) to cover both ends.

Not a use_figma skill. This runs in plain Node — no Figma file, no Plugin API. axe-core owns the rule database; this skill never invents rules.

Skill boundaries

  • Design-side visual a11y (contrast, focus rings, target size, color-only) → use lint-design-figma. Those rules are intentionally disabled here.
  • Per-component design scorecard → use audit-accessibility-figma.
  • Design-vs-code parity → use check-design-parity-figma (feed it the codeSpec.accessibility this scan can emit).
  • This skill does not use use_figma, so the figma-use conventions do not apply.

Why visual rules are disabled

JSDOM provides a DOM but no layout engine and no computed visual styles — there is nothing to measure pixels or rendered colors against. So axe's visual rules would always be "incomplete" or wrong. The scan disables them explicitly:

  • color-contrast and color-contrast-enhanced — need rendered colors.
  • link-in-text-block — needs surrounding text layout.
  • target-size — needs rendered box dimensions.

Everything structural/semantic (ARIA, roles, names, labels, alt, headings, landmarks, lang, dup IDs, tabindex, ~50 rules total) runs normally. For the visual half, run lint-design-figma on the design.

Usage

  1. Install deps once (in this skill's scripts/ dir):
    cd scripts && npm install
    
    Installs axe-core and jsdom.
  2. Run the scan against an HTML file or an inline string:
    node scan.mjs path/to/component.html
    node scan.mjs --html '<button>Save</button>'
    
    Optional flags:
    • --tags wcag22aa — filter to a WCAG tag set (wcag2a, wcag2aa, wcag21aa, wcag22aa, best-practice). Repeatable / comma-separated.
    • --context '#my-component' — scope the scan to a CSS selector.
    • --include-passing — include counts of passing / incomplete / inapplicable rules.
    • --map-to-codespec — also emit a codeSpecAccessibility object (semantic element, role, aria-label, focusVisible, keyboard interactions, disabled/error support) ready to drop into check-design-parity-figma's codeSpec.accessibility.
  3. Read the JSON on stdout: violations grouped by rule with severity (critical/warning/info from axe impact), wcagTags, helpUrl, and up to 10 offending nodes each, plus a summary.

A bare HTML fragment is auto-wrapped in <!DOCTYPE html><html lang="en">…<body>… before scanning.

Output shape

{
  "engine": "axe-core", "version": "4.x", "mode": "jsdom-structural",
  "note": "JSDOM mode: structural/semantic checks only. Visual rules disabled — use lint-design-figma.",
  "categories": [ { "rule": "button-name", "severity": "critical", "count": 1, "description": "...", "wcagTags": ["wcag2a","wcag412"], "helpUrl": "...", "nodes": [ { "html": "...", "target": ["button"], "failureSummary": "..." } ] } ],
  "summary": { "critical": 1, "warning": 0, "info": 0, "total": 1 }
}

Severity mapping: axe critical/serious → critical, moderate → warning, minor → info.

Comments

Markdown supported