@accesslint/core 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -33
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.iife.js +5 -5
- package/dist/index.js +1080 -981
- package/dist/rules/aria/aria-hidden-rules.d.ts.map +1 -1
- package/dist/rules/color/color-contrast.d.ts +3 -0
- package/dist/rules/color/color-contrast.d.ts.map +1 -0
- package/dist/rules/images/server-side-image-map.d.ts +1 -2
- package/dist/rules/images/server-side-image-map.d.ts.map +1 -1
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/keyboard/tabindex.d.ts +1 -2
- package/dist/rules/keyboard/tabindex.d.ts.map +1 -1
- package/dist/rules/structure/deprecated-elements.d.ts +2 -3
- package/dist/rules/structure/deprecated-elements.d.ts.map +1 -1
- package/dist/rules/structure/list-rules.d.ts.map +1 -1
- package/dist/rules/types.d.ts +0 -14
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/utils/color.d.ts +8 -0
- package/dist/rules/utils/color.d.ts.map +1 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -2,29 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Pure accessibility rule engine for WCAG auditing. 83 bundled rules, a declarative rule engine, and zero browser dependencies.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
Full audit (`runAudit`) on synthetic documents with a realistic mix of valid and invalid elements:
|
|
8
|
-
|
|
9
|
-
| Document size | ops/sec | mean |
|
|
10
|
-
| ------------- | ------: | ---: |
|
|
11
|
-
| 100 elements | 252 | 4.0 ms |
|
|
12
|
-
| 1,000 elements | 27 | 36.6 ms |
|
|
13
|
-
| 2,000 elements | 2.0 | 494 ms |
|
|
14
|
-
|
|
15
|
-
> Measured on GitHub Actions `ubuntu-latest` / Node 22 with `vitest bench` ([run](https://github.com/AccessLint/core/actions/runs/21695011947)).
|
|
16
|
-
|
|
17
|
-
### Concordance with axe-core
|
|
18
|
-
|
|
19
|
-
On a synthetic 500-element document exercising all rule categories:
|
|
5
|
+
## Highlights
|
|
20
6
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
| **Coverage** (agreement / axe findings) | **92%** |
|
|
7
|
+
- **Lightweight** — 29 KB gzipped (IIFE), with zero runtime dependencies
|
|
8
|
+
- **Chunked audits** — time-budgeted processing via [`createChunkedAudit`](#createchunkedauditdoc-document-chunkedaudit) to avoid long tasks on the main thread
|
|
9
|
+
- **Declarative rule engine** — define custom rules as JSON and compile them with [`compileDeclarativeRule`](#compiledeclarativerulespec-declarativerule-rule), no JavaScript required
|
|
10
|
+
- **ESM, CJS, and IIFE** — tree-shakable ES modules, CommonJS for Node, and a single-file IIFE for script injection into any page
|
|
11
|
+
- **Runs anywhere** — works with happy-dom, jsdom, and real browsers with no DOM polyfills or compatibility workarounds. Run accessibility audits in Vitest and React Testing Library using the same environment as the rest of your tests
|
|
12
|
+
- **MIT licensed**
|
|
28
13
|
|
|
29
14
|
## Install
|
|
30
15
|
|
|
@@ -34,6 +19,22 @@ npm install @accesslint/core
|
|
|
34
19
|
|
|
35
20
|
## Quick start
|
|
36
21
|
|
|
22
|
+
### Vitest + React Testing Library
|
|
23
|
+
|
|
24
|
+
Audit a rendered component in your existing test suite:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { render } from "@testing-library/react";
|
|
28
|
+
import { runAudit } from "@accesslint/core";
|
|
29
|
+
import { LoginForm } from "./LoginForm";
|
|
30
|
+
|
|
31
|
+
test("LoginForm has no accessibility violations", () => {
|
|
32
|
+
const { container } = render(<LoginForm />);
|
|
33
|
+
const { violations } = runAudit(container.ownerDocument);
|
|
34
|
+
expect(violations).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
37
38
|
### Playwright
|
|
38
39
|
|
|
39
40
|
Inject the library into the page and audit the live DOM:
|
|
@@ -65,21 +66,27 @@ test("page has no accessibility violations", async ({ page }) => {
|
|
|
65
66
|
Inject the library into the page and audit the live DOM:
|
|
66
67
|
|
|
67
68
|
```js
|
|
68
|
-
// cypress/
|
|
69
|
+
// cypress/e2e/a11y.cy.js
|
|
69
70
|
Cypress.Commands.add("audit", () => {
|
|
70
|
-
cy
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
return cy
|
|
72
|
+
.readFile("node_modules/@accesslint/core/dist/index.iife.js")
|
|
73
|
+
.then((src) => {
|
|
74
|
+
return cy.window().then((win) => {
|
|
75
|
+
win.eval(src);
|
|
76
|
+
const result = win.AccessLintCore.runAudit(win.document);
|
|
77
|
+
return result.violations;
|
|
78
|
+
});
|
|
75
79
|
});
|
|
76
|
-
});
|
|
77
80
|
});
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
describe("sample.html accessibility audit", () => {
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
cy.visit("sample.html");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("has no accessibility violations", () => {
|
|
88
|
+
cy.audit().should("have.length", 0);
|
|
89
|
+
});
|
|
83
90
|
});
|
|
84
91
|
```
|
|
85
92
|
|
|
@@ -269,6 +276,30 @@ Helpers for building custom rules:
|
|
|
269
276
|
| `video-caption` | A | 1.2.2 | Videos must have captions. |
|
|
270
277
|
| `audio-caption` | A | 1.2.1 | Audio elements should have a text alternative. |
|
|
271
278
|
|
|
279
|
+
## Benchmarks
|
|
280
|
+
|
|
281
|
+
Full audit (`runAudit`) on synthetic documents with a realistic mix of valid and invalid elements:
|
|
282
|
+
|
|
283
|
+
| Document size | ops/sec | mean |
|
|
284
|
+
| ------------- | ------: | ---: |
|
|
285
|
+
| 100 elements | 252 | 4.0 ms |
|
|
286
|
+
| 1,000 elements | 27 | 36.6 ms |
|
|
287
|
+
| 2,000 elements | 2.0 | 494 ms |
|
|
288
|
+
|
|
289
|
+
> Measured on GitHub Actions `ubuntu-latest` / Node 22 with `vitest bench` ([run](https://github.com/AccessLint/core/actions/runs/21695011947)).
|
|
290
|
+
|
|
291
|
+
### Concordance with axe-core
|
|
292
|
+
|
|
293
|
+
On a synthetic 500-element document exercising all rule categories:
|
|
294
|
+
|
|
295
|
+
| Metric | Value |
|
|
296
|
+
| ------ | ----: |
|
|
297
|
+
| Rules where both agree | 44 |
|
|
298
|
+
| @accesslint/core only | 9 |
|
|
299
|
+
| axe-core only | 4 |
|
|
300
|
+
| **Concordance** (agreement / core findings) | **83%** |
|
|
301
|
+
| **Coverage** (agreement / axe findings) | **92%** |
|
|
302
|
+
|
|
272
303
|
## Development
|
|
273
304
|
|
|
274
305
|
```sh
|