@accesslint/core 0.2.0 → 0.2.3
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 +8 -34
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.iife.js +5 -5
- package/dist/index.js +429 -388
- package/dist/rules/aria/aria-attr-audit.d.ts.map +1 -1
- package/dist/rules/color/color-contrast.d.ts.map +1 -1
- package/dist/rules/index.d.ts +1 -0
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/keyboard/interactive-rules.d.ts.map +1 -1
- package/dist/rules/utils/aria.d.ts +1 -0
- package/dist/rules/utils/aria.d.ts.map +1 -1
- package/dist/rules/utils/selector.d.ts +1 -0
- package/dist/rules/utils/selector.d.ts.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# @accesslint/core
|
|
2
2
|
|
|
3
|
-
Pure accessibility rule engine for WCAG auditing.
|
|
3
|
+
Pure accessibility rule engine for WCAG auditing. 84 bundled rules and zero browser dependencies.
|
|
4
4
|
|
|
5
5
|
## Highlights
|
|
6
6
|
|
|
7
|
-
- **Lightweight** —
|
|
7
|
+
- **Lightweight** — 31 KB gzipped (IIFE), with zero runtime dependencies
|
|
8
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
9
|
- **ESM, CJS, and IIFE** — tree-shakable ES modules, CommonJS for Node, and a single-file IIFE for script injection into any page
|
|
11
10
|
- **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
11
|
- **MIT licensed**
|
|
@@ -136,34 +135,16 @@ processNext();
|
|
|
136
135
|
Customize which rules are active.
|
|
137
136
|
|
|
138
137
|
```js
|
|
139
|
-
import { configureRules
|
|
138
|
+
import { configureRules } from "@accesslint/core";
|
|
140
139
|
|
|
141
140
|
configureRules({
|
|
142
141
|
disabledRules: ["heading-order"],
|
|
143
|
-
additionalRules: [compileDeclarativeRule(myCustomRule)],
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### `compileDeclarativeRule(spec: DeclarativeRule): Rule`
|
|
148
|
-
|
|
149
|
-
Compile a declarative rule definition into an executable rule. Supports six check types: `selector-exists`, `attribute-value`, `attribute-missing`, `attribute-regex`, `child-required`, and `child-invalid`.
|
|
150
|
-
|
|
151
|
-
```js
|
|
152
|
-
const rule = compileDeclarativeRule({
|
|
153
|
-
id: "no-autofocus",
|
|
154
|
-
selector: "[autofocus]",
|
|
155
|
-
check: { type: "selector-exists" },
|
|
156
|
-
impact: "serious",
|
|
157
|
-
message: "Autofocus attribute should not be used.",
|
|
158
|
-
description: "autofocus moves focus unexpectedly.",
|
|
159
|
-
wcag: ["2.4.3"],
|
|
160
|
-
level: "A",
|
|
161
142
|
});
|
|
162
143
|
```
|
|
163
144
|
|
|
164
145
|
### `rules`
|
|
165
146
|
|
|
166
|
-
Array of all
|
|
147
|
+
Array of all 84 bundled `Rule` objects.
|
|
167
148
|
|
|
168
149
|
### `getActiveRules(): Rule[]`
|
|
169
150
|
|
|
@@ -188,7 +169,7 @@ Helpers for building custom rules:
|
|
|
188
169
|
|
|
189
170
|
## Rules
|
|
190
171
|
|
|
191
|
-
|
|
172
|
+
84 rules covering WCAG 2.1 Level A and AA.
|
|
192
173
|
|
|
193
174
|
| Rule | Level | WCAG | Description |
|
|
194
175
|
| ---- | ----- | ---- | ----------- |
|
|
@@ -275,18 +256,11 @@ Helpers for building custom rules:
|
|
|
275
256
|
| `duplicate-id-aria` | A | 4.1.2 | IDs used in ARIA must be unique. |
|
|
276
257
|
| `video-caption` | A | 1.2.2 | Videos must have captions. |
|
|
277
258
|
| `audio-caption` | A | 1.2.1 | Audio elements should have a text alternative. |
|
|
259
|
+
| `color-contrast` | AA | 1.4.3 | Text must have sufficient color contrast. |
|
|
278
260
|
|
|
279
261
|
## Benchmarks
|
|
280
262
|
|
|
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)).
|
|
263
|
+
Full audit (`runAudit`) on synthetic documents with a realistic mix of valid and invalid elements.
|
|
290
264
|
|
|
291
265
|
### Concordance with axe-core
|
|
292
266
|
|
|
@@ -304,7 +278,7 @@ On a synthetic 500-element document exercising all rule categories:
|
|
|
304
278
|
|
|
305
279
|
```sh
|
|
306
280
|
npm install
|
|
307
|
-
npm test #
|
|
281
|
+
npm test # 410 tests
|
|
308
282
|
npm run bench # performance benchmarks
|
|
309
283
|
npm run build # produces dist/index.js, dist/index.cjs, dist/index.d.ts
|
|
310
284
|
```
|