axe-core 4.6.3 → 4.7.0-canary.4f18976

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
@@ -14,14 +14,12 @@ Axe is an accessibility testing engine for websites and other HTML-based user in
14
14
 
15
15
  ## The Accessibility Rules
16
16
 
17
- Axe-core has different types of rules, for WCAG 2.0 and 2.1 on level A and AA, as well as a number of best practices that help you identify common accessibility practices like ensuring every page has an `h1` heading, and to help you avoid "gotchas" in ARIA like where an ARIA attribute you used will get ignored.
17
+ Axe-core has different types of rules, for WCAG 2.0, 2.1, 2.2 on level A, AA and AAA as well as a number of best practices that help you identify common accessibility practices like ensuring every page has an `h1` heading, and to help you avoid "gotchas" in ARIA like where an ARIA attribute you used will get ignored. The complete list of rules, grouped WCAG level and best practice, can found in [doc/rule-descriptions.md](./doc/rule-descriptions.md).
18
18
 
19
19
  With axe-core, you can find **on average 57% of WCAG issues automatically**. Additionally, axe-core will return elements as "incomplete" where axe-core could not be certain, and manual review is needed.
20
20
 
21
21
  To catch bugs earlier in the development cycle we recommend using the [axe-linter vscode extension](https://marketplace.visualstudio.com/items?itemName=deque-systems.vscode-axe-linter). To improve test coverage even further we recommend the [intelligent guided tests](https://www.youtube.com/watch?v=AtsX0dPCG_4&feature=youtu.be&ab_channel=DequeSystems) in the [axe Extension](https://www.deque.com/axe/browser-extensions/).
22
22
 
23
- The complete list of rules, grouped WCAG level and best practice, can found in [doc/rule-descriptions.md](./doc/rule-descriptions.md).
24
-
25
23
  ## Getting started
26
24
 
27
25
  First download the package:
package/axe.d.ts CHANGED
@@ -190,12 +190,13 @@ declare namespace axe {
190
190
  help: string;
191
191
  };
192
192
  }
193
+ interface CheckMessages {
194
+ pass: string | { [key: string]: string };
195
+ fail: string | { [key: string]: string };
196
+ incomplete: string | { [key: string]: string };
197
+ }
193
198
  interface CheckLocale {
194
- [key: string]: {
195
- pass: string | { [key: string]: string };
196
- fail: string | { [key: string]: string };
197
- incomplete: string | { [key: string]: string };
198
- };
199
+ [key: string]: CheckMessages;
199
200
  }
200
201
  interface Locale {
201
202
  lang?: string;
@@ -237,7 +238,7 @@ declare namespace axe {
237
238
  }
238
239
  interface Spec {
239
240
  branding?: string | Branding;
240
- reporter?: ReporterVersion;
241
+ reporter?: ReporterVersion | string | AxeReporter;
241
242
  checks?: Check[];
242
243
  rules?: Rule[];
243
244
  standards?: Standards;
@@ -263,6 +264,10 @@ declare namespace axe {
263
264
  options?: any;
264
265
  matches?: string;
265
266
  enabled?: boolean;
267
+ metadata?: {
268
+ impact?: ImpactValue;
269
+ messages?: CheckMessages;
270
+ };
266
271
  }
267
272
  interface Rule {
268
273
  id: string;
@@ -277,6 +282,7 @@ declare namespace axe {
277
282
  tags?: string[];
278
283
  matches?: string;
279
284
  reviewOnFail?: boolean;
285
+ metadata?: Omit<RuleMetadata, 'ruleId'>;
280
286
  }
281
287
  interface AxePlugin {
282
288
  id: string;
@@ -319,6 +325,40 @@ declare namespace axe {
319
325
  frameSelector: CrossTreeSelector;
320
326
  frameContext: FrameContextObject;
321
327
  }
328
+
329
+ interface RawNodeResult<T extends 'passed' | 'failed' | 'incomplete'> {
330
+ any: CheckResult[];
331
+ all: CheckResult[];
332
+ none: CheckResult[];
333
+ impact: ImpactValue | null;
334
+ result: T;
335
+ }
336
+
337
+ interface RawResult extends Omit<Result, 'nodes'> {
338
+ inapplicable: [];
339
+ passes: RawNodeResult<'passed'>[];
340
+ incomplete: RawNodeResult<'incomplete'>[];
341
+ violations: RawNodeResult<'failed'>[];
342
+ pageLevel: boolean;
343
+ result: 'failed' | 'passed' | 'incomplete' | 'inapplicable';
344
+ }
345
+
346
+ type AxeReporter<T = unknown> = (
347
+ rawResults: RawResult[],
348
+ option: RunOptions,
349
+ callback: (report: T) => void
350
+ ) => void;
351
+
352
+ interface VirtualNode {
353
+ actualNode?: Node;
354
+ shadowId?: string;
355
+ children?: VirtualNode[];
356
+ parent?: VirtualNode;
357
+ attr(attr: string): string | null;
358
+ hasAttr(attr: string): boolean;
359
+ props: { [key: string]: unknown };
360
+ }
361
+
322
362
  interface Utils {
323
363
  getFrameContexts: (
324
364
  context?: ElementContext,
@@ -326,7 +366,9 @@ declare namespace axe {
326
366
  ) => FrameContext[];
327
367
  shadowSelect: (selector: CrossTreeSelector) => Element | null;
328
368
  shadowSelectAll: (selector: CrossTreeSelector) => Element[];
369
+ getStandards(): Required<Standards>;
329
370
  }
371
+
330
372
  interface EnvironmentData {
331
373
  testEngine: TestEngine;
332
374
  testRunner: TestRunner;
@@ -436,6 +478,35 @@ declare namespace axe {
436
478
  */
437
479
  function frameMessenger(frameMessenger: FrameMessenger): void;
438
480
 
481
+ /**
482
+ * Setup axe-core so axe.common functions can work properly.
483
+ */
484
+ function setup(node?: Element | Document): VirtualNode;
485
+
486
+ /**
487
+ * Clean up axe-core tree and caches. `axe.run` will call this function at the end of the run so there's no need to call it yourself afterwards.
488
+ */
489
+ function teardown(): void;
490
+
491
+ /**
492
+ * Check if a reporter is registered
493
+ */
494
+ function hasReporter(reporterName: string): boolean;
495
+
496
+ /**
497
+ * Get a reporter based the name it is registered with
498
+ */
499
+ function getReporter<T>(reporterName: string): AxeReporter<T>;
500
+
501
+ /**
502
+ * Register a new reporter, optionally setting it as the default
503
+ */
504
+ function addReporter<T>(
505
+ reporterName: string,
506
+ reporter: AxeReporter<T>,
507
+ isDefault?: boolean
508
+ ): void;
509
+
439
510
  // axe.frameMessenger
440
511
  type FrameMessenger = {
441
512
  open: (topicHandler: TopicHandler) => Close | void;