npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@a11y-guard/core

v1.0.0

Published

Core rule engine and compliance mappings for a11y-guard

Readme

@a11y-guard/core

The rule engine and compliance database that powers a11y-guard. Audits HTML strings against 36 WCAG rules and maps every violation to the exact law and jurisdiction that requires it.

Install

npm install @a11y-guard/core
# or
pnpm add @a11y-guard/core

Quick start

import { runAudit, format } from '@a11y-guard/core';

const result = runAudit({
  html: '<img src="logo.png">',
  regions: ['US', 'EU'],
  level: 'AA',
});

console.log(result.violations);
// [{ ruleId: 'missing-alt-text', severity: 'error', laws: ['ADA', 'EAA'], regions: ['US', 'EU'], ... }]

// Pretty-print to stdout
process.stdout.write(format(result, { regions: ['US', 'EU'] }, 'index.html'));

API

runAudit(options)

import { runAudit } from '@a11y-guard/core';

const result = runAudit({
  html: string,            // HTML string to audit (required)
  file?: string,           // filename shown in violation output
  isComponentFile?: boolean, // true for .tsx/.jsx — skips document-level rules
  regions?: Region[],      // filter rules to these jurisdictions
  laws?: Law[],            // filter rules to these laws
  disabilityTypes?: DisabilityType[],
  level?: 'A' | 'AA' | 'AAA',        // default 'AA'
  wcagVersion?: '2.0' | '2.1' | '2.2', // default '2.1'
  rules?: Record<string, 'error' | 'warning' | 'info' | 'off'>, // per-rule overrides
});

Returns an AuditResult:

interface AuditResult {
  violations: Violation[];   // severity === 'error'
  warnings: Violation[];     // severity === 'warning' | 'info'
  passed: number;            // rules that ran with no findings
  summary: ComplianceSummary;
}

interface Violation {
  ruleId: string;
  severity: 'error' | 'warning' | 'info';
  message: string;
  suggestion: string;
  element?: string;          // outerHTML snippet
  file?: string;
  line?: number;
  col?: number;
  laws: Law[];               // laws that require this criterion
  regions: Region[];         // jurisdictions affected
  wcagCriterion: WcagCriterion;
}

format(result, config, file)

Returns a formatted string. Uses the reporter field in config:

| reporter | Output | |---|---| | 'pretty' (default) | Human-readable terminal output | | 'json' | Full JSON object | | 'sarif' | SARIF 2.1 (GitHub Code Scanning) | | 'github-actions' | ::error / ::warning annotations |

formatHtml(results, config)

Generates a self-contained dark-theme HTML report aggregating multiple files:

import { formatHtml } from '@a11y-guard/core';
import { writeFileSync } from 'fs';

const report = formatHtml(
  [{ result, file: 'src/App.tsx' }, { result: result2, file: 'index.html' }],
  { regions: ['US', 'EU'] }
);
writeFileSync('a11y-report.html', report);

parseJsx(source, filename?)

Converts JSX/TSX source to an HTML string suitable for runAudit. Used internally by the CLI for .tsx/.jsx files.

import { parseJsx, runAudit } from '@a11y-guard/core';
import { readFileSync } from 'fs';

const source = readFileSync('src/Button.tsx', 'utf-8');
const html = parseJsx(source, 'src/Button.tsx');
const result = runAudit({ html, isComponentFile: true, regions: ['US'] });

defineConfig(config)

Type-safe helper for config files:

// a11y-guard.config.ts
import { defineConfig } from '@a11y-guard/core';

export default defineConfig({
  regions: ['US', 'EU'],
  level: 'AA',
  failOn: 'error',
  rules: {
    'color-contrast': 'error',
    'focus-visible': 'warning',
  },
});

Regions

| Code | Jurisdiction | Primary law(s) | |---|---|---| | US | United States | ADA, Section 508 | | EU | European Union | EAA, EN 301 549 | | UK | United Kingdom | Equality Act, PSBAR | | CA | Canada | AODA, ACA | | AU | Australia | DDA | | DE | Germany | BITV 2.0 | | FR | France | RGAA | | BR | Brazil | LBI 13.146 | | JP | Japan | JIS X 8341-3 | | NZ IL IN ES NL SE NO DK FI | — | EN 301 549 / regional |

Rules

36 rules across six categories:

Visualmissing-alt-text, color-contrast, non-text-contrast, text-resize, images-of-text, focus-visible, target-size

Auditoryvideo-captions, audio-description, live-captions, audio-control

Motorkeyboard-accessible, keyboard-trap, focus-order, label-in-name, pointer-gestures, skip-links

Cognitivepage-title, link-purpose, error-identification, error-suggestion, label-association, language-parts, on-input, consistent-navigation, timeout-adjustable

Seizureanimation-from-interactions

Structuralheading-order, landmark-regions, aria-required-attr, aria-valid-attr, aria-valid-attr-value, duplicate-id, html-has-lang, list-structure, table-headers

License

MIT — see LICENSE in the root of the repository.