API Reference

runAudit(document: Document): AuditResult

Run all active rules against a document and return violations.

import { runAudit } from "@accesslint/core";

const result = runAudit(document);

AuditResult

interface AuditResult {
  url: string;           // document.URL
  timestamp: number;     // Date.now() at audit start
  violations: Violation[];
  ruleCount: number;     // number of rules that ran
}

Violation

interface Violation {
  ruleId: string;        // e.g. "accesslint-011"
  selector: string;      // CSS selector of the element
  html: string;          // HTML snippet
  impact: "critical" | "serious" | "moderate" | "minor";
  message: string;       // Human-readable description
  context?: string;      // Surrounding context
  aiContext?: string;     // Additional context for AI guidance
}

configureRules(options: ConfigureOptions): void

Configure which rules are active.

import { configureRules } from "@accesslint/core";

configureRules({
  disabled: ["accesslint-033"], // disable specific rules by ID
});

getRuleById(id: string): Rule | undefined

Look up a rule by its ID.

import { getRuleById } from "@accesslint/core";

const rule = getRuleById("accesslint-011");
// rule.description → "Images must have alternate text..."

getActiveRules(): Rule[]

Get all currently active rules (respects configureRules).

rules: Rule[]

The full array of all rules (always includes all rules regardless of configuration).

Rule

interface Rule {
  id: string;
  actRuleIds?: string[];     // Related ACT rule IDs
  wcag: string[];            // WCAG criteria, e.g. ["1.1.1"]
  level: "A" | "AA" | "AAA";
  tags?: string[];           // e.g. ["best-practice"]
  description: string;
  guidance?: string;         // Remediation guidance for AI
  prompt?: string;           // Tailored prompt for AI explanation
  run(doc: Document): Violation[];
}

createChunkedAudit(document: Document): ChunkedAudit

Create a chunked audit that yields control between rule batches, useful for keeping the main thread responsive.

import { createChunkedAudit } from "@accesslint/core";

const audit = createChunkedAudit(document);
while (!audit.done) {
  await audit.next(); // runs a batch of rules
  // update progress UI...
}
const result = audit.result;

clearAllCaches(): void

Clear internal caches. Call between audits if the DOM has changed significantly.

Utilities

These are exported for custom rule authors:

  • getAccessibleName(element: Element): string
  • getComputedRole(element: Element): string | null
  • getImplicitRole(element: Element): string | null
  • isAriaHidden(element: Element): boolean
  • getSelector(element: Element): string
  • getHtmlSnippet(element: Element): string

Internationalization

import { registerLocale, translateViolations, localeEs } from "@accesslint/core";

registerLocale("es", localeEs);
const translated = translateViolations(violations, "es");