项目作者: m4thieulavoie

项目描述 :
Axe reporter injected in the browser page if it detects any accessibility issue
高级语言: TypeScript
项目地址: git://github.com/m4thieulavoie/axe-browser-reporter.git
创建时间: 2020-12-29T16:47:33Z
项目社区:https://github.com/m4thieulavoie/axe-browser-reporter

开源协议:MIT License

下载


axe-browser-reporter

code style: prettier
Renovate enabled
npm version
Downloads
CircleCI


demo

Description

Axe reporter injected in the browser page if it detects any accessibility issue.

This project is made to make the accessibility development a top priority. As soon as an a11y rule is broken, the popup will simply appear and let you know how you can fix it. We strongly rely on axe-core

Installation

  1. npm i axe-browser-reporter

Usage

In order for the plugin to kick in, make sure that your global environment variable process.env.NODE_ENV does equal 'development'. Otherwise, axe-browser-reporter won’t run at all.

In your project, import axe-browser-reporter at the root of your project (e.g. an index.(js|ts) file).

  1. import bootstrap from "axe-browser-reporter";
  2. // Any setup code at root level of your app
  3. bootstrap();

Options

Some options can be passed to bootstrap in order to tweak axe under the hood

  1. import bootstrap from "axe-browser-reporter";
  2. // Default values
  3. bootstrap({
  4. allowlist: [],
  5. runIf: () => process.env?.NODE_ENV === "development",
  6. });

allowlist

If there are rules you want axe-browser-reporter not to notify you about, you can specify them in an array of string like such. The argument is the id given from axe. The full list can be found here

  1. import bootstrap from "axe-browser-reporter";
  2. // Will ignore color-contrast and frame-tested a11y rules
  3. bootstrap({
  4. allowlist: ["color-contrast", "frame-tested"],
  5. });

runIf

If you want to change the condition on wheter to run axe-browser-reporter or not, you can specify a runIf attribute. Its signature is () => boolean

  1. import bootstrap from "axe-browser-reporter";
  2. const myBoolean = randomCondition ? true : false;
  3. bootstrap({
  4. runIf: () => myBoolean,
  5. });