@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 CHANGED
@@ -1,12 +1,11 @@
1
1
  # @accesslint/core
2
2
 
3
- Pure accessibility rule engine for WCAG auditing. 83 bundled rules, a declarative rule engine, and zero browser dependencies.
3
+ Pure accessibility rule engine for WCAG auditing. 84 bundled rules and zero browser dependencies.
4
4
 
5
5
  ## Highlights
6
6
 
7
- - **Lightweight** — 29 KB gzipped (IIFE), with zero runtime dependencies
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, compileDeclarativeRule } from "@accesslint/core";
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 83 bundled `Rule` objects.
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
- 83 rules covering WCAG 2.1 Level A and AA.
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 # 394 tests
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
  ```