This file provides guidance to Claude Code when working with the accessibility-scanner repository.
accessibility-scanner is a TypeScript-based accessibility scanner that implements WCAG 2.0 Level A & AA rules. The project provides a scanner that can detect accessibility issues in web content, following standards from the Axe-core rule set and W3C Accessibility Conformance Testing (ACT) rules.
accessibility-scanner/
├── src/
│ ├── app.ts # Main application entry point
│ ├── scanner.ts # Core scanner implementation
│ ├── utils.ts # Utility functions
│ ├── utils/ # Additional utility modules
│ │ └── aria-attrs.ts # ARIA attribute utilities
│ └── rules/ # Individual accessibility rule implementations
├── tests/ # Test files
├── scripts/ # Build and utility scripts
├── package.json # Node.js dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
- Node.js (version compatible with package-lock.json)
- npm
npm installnpm run buildCompiles TypeScript to JavaScript using tsc.
npm run lintRuns ESLint on TypeScript files in the src directory.
npm run formatAuto-fixes linting issues using ESLint's --fix flag.
npm testRuns the formatter and then executes tests using web-test-runner.
npm run test:watchRuns tests in watch mode for continuous development.
npm startStarts the web development server.
npm run build:readmeRegenerates the README.md file using the generate-readme.ts script.
The src/rules/ directory contains individual accessibility rule implementations. Each rule is a TypeScript file that:
- Implements a specific WCAG or Axe-core accessibility rule
- Follows a consistent structure for rule checking
- Includes rule metadata (id, description, tags, etc.)
Example rules include:
aria-hidden-focus.ts- Ensures aria-hidden elements don't contain focusable elementsbutton-name.ts- Ensures buttons have discernible textimage-alt.ts- Ensures images have alternate textlabel.ts- Ensures form elements have labels
The core scanner (src/scanner.ts) orchestrates the execution of all rules against web content.
Tests are located in the tests/ directory and use:
@web/test-runnerfor running tests@open-wc/testingfor web component testing utilities- Playwright for browser automation
- Language: TypeScript
- Module System: ES Modules (specified in package.json)
- Linting: ESLint with
@koddsson/eslint-config - Formatting: Automated via
npm run format
- Use kebab-case for file names (e.g.,
aria-hidden-focus.ts) - Test files should mirror source file names
- Follow ESLint rules configured in
eslint.config.js - Run
npm run formatbefore committing to ensure code consistency
Always run tests before submitting changes:
npm test- Tests should be comprehensive and cover edge cases
- Use the existing test infrastructure with
@web/test-runner - Follow patterns from existing test files in the
tests/directory
The project uses:
verbose-test-reporter.jsfor detailed test output@web/test-runner-junit-reporterfor JUnit-style reports
- Create a new TypeScript file in
src/rules/following the naming convention - Implement the rule following patterns from existing rules
- Add corresponding tests in the
tests/directory - Update the README if necessary using
npm run build:readme - Run
npm testto ensure all tests pass
- Update
package.json - Run
npm installto updatepackage-lock.json - Test thoroughly to ensure compatibility
- Make changes to the relevant file in
src/rules/ - Update or add tests as needed
- Run
npm run lintandnpm test - Verify the change doesn't break existing functionality
Compiled files are output to the dist/src/ directory as specified in package.json:
- Main export:
./dist/src/scanner.js - Rule exports:
./dist/src/rules/*.js
- ACT Rules: W3C Accessibility Conformance Testing rules referenced in
testcases.json - Axe Rules: Deque University rules documented in the README
- Rules Data:
rules.jsoncontains metadata about implemented rules - Test Cases:
testcases.jsoncontains test scenarios
testcases.json is the canonical source of truth for which ACT rules and test cases this scanner is measured against. It is mirrored from the W3C ACT Task Force feed (https://www.w3.org/WAI/content-assets/wcag-act-rules/testcases.json).
- Run
npm run sync:testcasesbefore starting work. This pulls the latest upstreamtestcases.jsonso any rule additions, removals, or test case changes from the ACT Task Force are reflected before you make decisions about what to implement, skip, or update. - Never hand-edit
testcases.json. It must only be modified bynpm run sync:testcases. If something looks wrong, fix it upstream — do not patch the local file. The scanner's correctness is measured against this file, so editing it directly invalidates that signal.
- Always run
npm run sync:testcasesat the start of a session that touches ACT rules — it's the guiding light for what's correct. - Never modify
testcases.jsonby hand. Treat it as read-only output of the sync script. - Always run
npm run format,npm testandnpm run build:readmebefore committing changes - The project follows TypeScript strict mode
- Accessibility rules should follow WCAG 2.0 Level A & AA standards
- When adding rules, check
rules.jsonand the README for existing implementations - Test coverage is important - add tests for any new functionality
- The project uses Web Components and requires browser testing via Playwright