@accesslint/core 0.5.1 → 0.6.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.
Files changed (52) hide show
  1. package/README.md +18 -39
  2. package/dist/i18n/en.d.ts.map +1 -1
  3. package/dist/i18n/es.d.ts.map +1 -1
  4. package/dist/index.cjs +5 -5
  5. package/dist/index.iife.js +5 -5
  6. package/dist/index.js +2062 -1475
  7. package/dist/rules/aria/aria-allowed-attr.d.ts.map +1 -1
  8. package/dist/rules/aria/aria-children-parent.d.ts.map +1 -1
  9. package/dist/rules/aria/aria-hidden-rules.d.ts.map +1 -1
  10. package/dist/rules/aria/aria-name-rules.d.ts.map +1 -1
  11. package/dist/rules/aria/aria-prohibited-attr.d.ts.map +1 -1
  12. package/dist/rules/aria/aria-required-attr.d.ts.map +1 -1
  13. package/dist/rules/aria/aria-roles.d.ts.map +1 -1
  14. package/dist/rules/aria/aria-valid-attr-value.d.ts.map +1 -1
  15. package/dist/rules/aria/aria-valid-attr.d.ts.map +1 -1
  16. package/dist/rules/aria/button-name.d.ts.map +1 -1
  17. package/dist/rules/aria/presentation-role-conflict.d.ts.map +1 -1
  18. package/dist/rules/aria/presentational-children-focusable.d.ts +3 -0
  19. package/dist/rules/aria/presentational-children-focusable.d.ts.map +1 -0
  20. package/dist/rules/aria/summary-name.d.ts.map +1 -1
  21. package/dist/rules/color/color-contrast.d.ts +1 -0
  22. package/dist/rules/color/color-contrast.d.ts.map +1 -1
  23. package/dist/rules/engine.d.ts.map +1 -1
  24. package/dist/rules/forms/autocomplete-valid.d.ts.map +1 -1
  25. package/dist/rules/forms/label-content-name-mismatch.d.ts.map +1 -1
  26. package/dist/rules/forms/label.d.ts.map +1 -1
  27. package/dist/rules/images/img-alt.d.ts.map +1 -1
  28. package/dist/rules/images/input-image-alt.d.ts.map +1 -1
  29. package/dist/rules/images/object-alt.d.ts.map +1 -1
  30. package/dist/rules/images/svg-img-alt.d.ts.map +1 -1
  31. package/dist/rules/index.d.ts.map +1 -1
  32. package/dist/rules/keyboard/focus-visible.d.ts +3 -0
  33. package/dist/rules/keyboard/focus-visible.d.ts.map +1 -0
  34. package/dist/rules/keyboard/interactive-rules.d.ts.map +1 -1
  35. package/dist/rules/language/html-has-lang.d.ts.map +1 -1
  36. package/dist/rules/links/link-name.d.ts.map +1 -1
  37. package/dist/rules/media/media-captions.d.ts.map +1 -1
  38. package/dist/rules/structure/document-rules.d.ts.map +1 -1
  39. package/dist/rules/structure/frame-rules.d.ts.map +1 -1
  40. package/dist/rules/structure/heading-rules.d.ts.map +1 -1
  41. package/dist/rules/structure/meta-rules.d.ts +1 -0
  42. package/dist/rules/structure/meta-rules.d.ts.map +1 -1
  43. package/dist/rules/structure/orientation-lock.d.ts +3 -0
  44. package/dist/rules/structure/orientation-lock.d.ts.map +1 -0
  45. package/dist/rules/structure/text-spacing-rules.d.ts +5 -0
  46. package/dist/rules/structure/text-spacing-rules.d.ts.map +1 -0
  47. package/dist/rules/tables/table-headers.d.ts.map +1 -1
  48. package/dist/rules/types.d.ts +4 -2
  49. package/dist/rules/types.d.ts.map +1 -1
  50. package/dist/rules/utils/color.d.ts +16 -0
  51. package/dist/rules/utils/color.d.ts.map +1 -1
  52. package/package.json +5 -1
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @accesslint/core
2
2
 
3
- Pure accessibility rule engine for WCAG auditing. 84 bundled rules and zero browser dependencies.
3
+ Pure accessibility rule engine for WCAG auditing. 85 bundled rules (69 active by default) and zero browser dependencies.
4
4
 
5
5
  ## Highlights
6
6
 
7
- - **Lightweight** — 31 KB gzipped (IIFE), with zero runtime dependencies
7
+ - **Lightweight** — 38 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
9
  - **ESM, CJS, and IIFE** — tree-shakable ES modules, CommonJS for Node, and a single-file IIFE for script injection into any page
10
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
@@ -132,23 +132,33 @@ processNext();
132
132
 
133
133
  ### `configureRules(options: ConfigureOptions)`
134
134
 
135
- Customize which rules are active.
135
+ Customize which rules are active. Twenty rules are disabled by default (see `defaultDisabledRuleIds`); use `enabledRules` to re-enable them.
136
136
 
137
137
  ```js
138
138
  import { configureRules } from "@accesslint/core";
139
139
 
140
+ // Disable a rule
140
141
  configureRules({
141
142
  disabledRules: ["heading-order"],
142
143
  });
144
+
145
+ // Re-enable a default-disabled rule
146
+ configureRules({
147
+ enabledRules: ["aria-roles"],
148
+ });
143
149
  ```
144
150
 
145
151
  ### `rules`
146
152
 
147
- Array of all 84 bundled `Rule` objects.
153
+ Array of all 85 bundled `Rule` objects.
154
+
155
+ ### `defaultDisabledRuleIds`
156
+
157
+ `Set<string>` of the 16 rule IDs that are disabled by default. These can be re-enabled via `configureRules({ enabledRules: [...] })`.
148
158
 
149
159
  ### `getActiveRules(): Rule[]`
150
160
 
151
- Returns bundled rules (minus disabled) plus any additional rules from `configureRules()`.
161
+ Returns bundled rules minus default-disabled and user-disabled rules (plus any re-enabled or additional rules from `configureRules()`).
152
162
 
153
163
  ### `getRuleById(id: string): Rule | undefined`
154
164
 
@@ -169,7 +179,7 @@ Helpers for building custom rules:
169
179
 
170
180
  ## Rules
171
181
 
172
- 84 rules covering WCAG 2.1 Level A and AA.
182
+ 69 rules active by default, covering WCAG 2.1 Level A and AA. An additional 16 rules are bundled but disabled by default; re-enable them via `configureRules({ enabledRules: [...] })`.
173
183
 
174
184
  | Rule | Level | WCAG | Description |
175
185
  | ---- | ----- | ---- | ----------- |
@@ -195,13 +205,11 @@ Helpers for building custom rules:
195
205
  | `form-field-multiple-labels` | A | — | Form fields should not have multiple labels. |
196
206
  | `select-name` | A | 4.1.2 | Select elements must have a label. |
197
207
  | `input-button-name` | A | 4.1.2 | Input buttons must have discernible text. |
198
- | `autocomplete-valid` | AA | 1.3.5 | Autocomplete must use valid values. |
199
208
  | `label-content-name-mismatch` | A | 2.5.3 | Accessible name must contain visible text. |
200
209
  | `label-title-only` | A | — | Forms should not use title as the only label. |
201
210
  | `tabindex` | A | — | tabindex should not be greater than 0. |
202
211
  | `focus-order-semantics` | A | — | Focusable elements must have an appropriate role. |
203
212
  | `nested-interactive` | A | 4.1.2 | Interactive controls must not be nested. |
204
- | `scrollable-region-focusable` | A | 2.1.1 | Scrollable regions must be keyboard accessible. |
205
213
  | `accesskeys` | A | — | Accesskey values must be unique. |
206
214
  | `heading-order` | A | — | Heading levels should increase by one. |
207
215
  | `empty-heading` | A | — | Headings must have discernible text. |
@@ -216,41 +224,28 @@ Helpers for building custom rules:
216
224
  | `landmark-complementary-is-top-level` | A | — | Aside landmark should be top-level. |
217
225
  | `landmark-unique` | A | — | Landmarks of the same type should have unique labels. |
218
226
  | `region` | A | — | All content should be within landmarks. |
219
- | `list` | A | 1.3.1 | Lists must only contain valid children. |
220
- | `dlitem` | A | 1.3.1 | `<dt>`/`<dd>` must be in a `<dl>`. |
221
- | `definition-list` | A | 1.3.1 | `<dl>` must only contain valid children. |
222
227
  | `aria-roles` | A | 4.1.2 | ARIA role values must be valid. |
223
- | `aria-valid-attr` | A | 4.1.2 | ARIA attributes must be correctly spelled. |
228
+ | `aria-valid-attr` | A | 4.1.2 | ARIA attributes must be valid (correctly spelled). |
224
229
  | `aria-valid-attr-value` | A | 4.1.2 | ARIA attributes must have valid values. |
225
230
  | `aria-required-attr` | A | 4.1.2 | Required ARIA attributes must be present. |
226
231
  | `aria-allowed-attr` | A | 4.1.2 | ARIA attributes must be allowed for the role. |
227
- | `aria-allowed-role` | A | 4.1.2 | ARIA role must be appropriate for the element. |
228
- | `aria-required-children` | A | 4.1.2 | Required child roles must be present. |
229
- | `aria-required-parent` | A | 4.1.2 | Required parent roles must be present. |
230
232
  | `aria-hidden-body` | A | 4.1.2 | `aria-hidden` must not be on `<body>`. |
231
233
  | `aria-hidden-focus` | A | 4.1.2 | `aria-hidden` regions must not contain focusable elements. |
232
234
  | `aria-command-name` | A | 4.1.2 | ARIA commands must have an accessible name. |
233
235
  | `aria-input-field-name` | A | 4.1.2 | ARIA input fields must have an accessible name. |
234
236
  | `aria-toggle-field-name` | A | 4.1.2 | ARIA toggle fields must have an accessible name. |
235
237
  | `aria-meter-name` | A | 4.1.2 | ARIA meters must have an accessible name. |
236
- | `aria-progressbar-name` | A | 4.1.2 | ARIA progressbars must have an accessible name. |
237
238
  | `aria-dialog-name` | A | 4.1.2 | ARIA dialogs must have an accessible name. |
238
- | `aria-tooltip-name` | A | 4.1.2 | ARIA tooltips must have an accessible name. |
239
239
  | `aria-treeitem-name` | A | 4.1.2 | ARIA treeitems must have an accessible name. |
240
- | `aria-prohibited-attr` | A | 4.1.2 | Prohibited ARIA attributes must not be used. |
241
240
  | `presentation-role-conflict` | A | 4.1.2 | Presentation role must not conflict with focusability. |
242
241
  | `button-name` | A | 4.1.2 | Buttons must have discernible text. |
243
242
  | `summary-name` | A | 4.1.2 | `<summary>` elements must have an accessible name. |
244
243
  | `link-name` | A | 2.4.4, 4.1.2 | Links must have discernible text. |
245
244
  | `skip-link` | A | 2.4.1 | Skip links must point to a valid target. |
246
- | `link-in-text-block` | A | 1.4.1 | Links in text must be distinguishable by more than color. |
247
245
  | `html-has-lang` | A | 3.1.1 | `<html>` must have a `lang` attribute. |
248
246
  | `html-lang-valid` | A | 3.1.1 | `lang` on `<html>` must be valid. |
249
- | `valid-lang` | AA | 3.1.2 | `lang` attributes must have valid values. |
250
247
  | `html-xml-lang-mismatch` | A | 3.1.1 | `lang` and `xml:lang` must match. |
251
248
  | `td-headers-attr` | A | 1.3.1 | Table headers references must be valid. |
252
- | `th-has-data-cells` | A | 1.3.1 | Table headers should have data cells. |
253
- | `td-has-header` | A | 1.3.1 | Data cells in large tables should have headers. |
254
249
  | `scope-attr-valid` | A | 1.3.1 | `scope` attribute must have a valid value. |
255
250
  | `empty-table-header` | A | — | Table headers should have visible text. |
256
251
  | `duplicate-id-aria` | A | 4.1.2 | IDs used in ARIA must be unique. |
@@ -258,27 +253,11 @@ Helpers for building custom rules:
258
253
  | `audio-caption` | A | 1.2.1 | Audio elements should have a text alternative. |
259
254
  | `color-contrast` | AA | 1.4.3 | Text must have sufficient color contrast. |
260
255
 
261
- ## Benchmarks
262
-
263
- Full audit (`runAudit`) on synthetic documents with a realistic mix of valid and invalid elements.
264
-
265
- ### Concordance with axe-core
266
-
267
- On a synthetic 500-element document exercising all rule categories:
268
-
269
- | Metric | Value |
270
- | ------ | ----: |
271
- | Rules where both agree | 44 |
272
- | @accesslint/core only | 9 |
273
- | axe-core only | 4 |
274
- | **Concordance** (agreement / core findings) | **83%** |
275
- | **Coverage** (agreement / axe findings) | **92%** |
276
-
277
256
  ## Development
278
257
 
279
258
  ```sh
280
259
  npm install
281
- npm test # 410 tests
260
+ npm test # 498 tests
282
261
  npm run bench # performance benchmarks
283
262
  npm run build # produces dist/index.js, dist/index.cjs, dist/index.d.ts
284
263
  ```
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,EAAE,EAAE,SAsFhB,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,EAAE,EAAE,SA8FhB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../src/i18n/es.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,EAAE,EAAE,SAsFhB,CAAC"}
1
+ {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../src/i18n/es.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,EAAE,EAAE,SA8FhB,CAAC"}