Skip to content

Commit

Permalink
feat: Deprecate impact on checks, use rules instead (#4114)
Browse files Browse the repository at this point in the history
* feat: Deprecate impact on checks, use rules instead

* Update docs
  • Loading branch information
WilcoFiers authored Aug 1, 2023
1 parent 637bf6c commit 2cc5547
Show file tree
Hide file tree
Showing 104 changed files with 106 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build/rule-generator/get-files-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const getRuleSpecFileMeta = (ruleName, ruleHasMatches, ruleChecks) => {
content: JSON.stringify(
{
id: ruleName,
impact: '',
selector: '*',
...(ruleHasMatches && {
matches: `${ruleName}-matches`
Expand Down Expand Up @@ -121,7 +122,6 @@ const getCheckSpecFileMeta = (name, dir) => {
id: `${name}`,
evaluate: `${name}-evaluate`,
metadata: {
impact: '',
messages: {
pass: '',
fail: '',
Expand Down
3 changes: 2 additions & 1 deletion build/tasks/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function createSchemas() {
conform: 'Must have at least two valid messages'
}
},
// @deprecated: Use impact on rules instead
impact: {
required: true,
type: 'string',
enum: ['minor', 'moderate', 'serious', 'critical']
}
Expand All @@ -134,6 +134,7 @@ function createSchemas() {
type: 'string'
},
impact: {
required: true,
type: 'string',
enum: ['minor', 'moderate', 'serious', 'critical']
},
Expand Down
2 changes: 1 addition & 1 deletion doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ axe.configure({
- The rules attribute is an Array of rule objects
- each rule object can contain the following attributes
- `id` - string(required). This uniquely identifies the rule. If the rule already exists, it will be overridden with any of the attributes supplied. The attributes below that are marked required, are only required for new rules.
- `impact` - string(optional). Override the impact defined by checks
- `impact` - string(required). Sets the impact of that rule's results
- `reviewOnFail` - boolean(option, default `false`). Override the result of a rule to return "Needs Review" rather than "Violation" if the rule fails.
- `selector` - string(optional, default `*`). A [CSS selector](./developer-guide.md#supported-css-selectors) used to identify the elements that are passed into the rule for evaluation.
- `excludeHidden` - boolean(optional, default `true`). This indicates whether elements that are hidden from all users are to be passed into the rule for evaluation.
Expand Down
4 changes: 2 additions & 2 deletions doc/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ After execution, a Check will return `true`, `false`, or `undefined` depending o
Rules are defined by JSON files in the [lib/rules directory](../lib/rules). The JSON object is used to seed the [Rule object](../lib/core/base/rule.js#L30). A valid Rule JSON consists of the following:

- `id` - `String` A unique name of the Rule.
- `impact` - `String` (one of `minor`, `moderate`, `serious`, or `critical`). Sets the impact of the results of this rule
- `selector` - **optional** `String` which is a [CSS selector](#supported-css-selectors) that specifies the elements of the page on which the Rule runs. axe-core will look inside of the light DOM and _open_ [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM) trees for elements matching the provided selector. If omitted, the rule will run against every node.
- `excludeHidden` - **optional** `Boolean` Whether the rule should exclude hidden elements. Defaults to `true`.
- `enabled` - **optional** `Boolean` Whether the rule is enabled by default. Defaults to `true`.
- `pageLevel` - **optional** `Boolean` Whether the rule is page level. Page level rules will only run if given an entire `document` as context.
- `matches` - **optional** `String` The ID of the filtering function that will exclude elements that match the `selector` property. See the [`metadata-function-map`](../lib/core/base/metadata-function-map.js) file for all defined IDs.
- `impact` - **optional** `String` (one of `minor`, `moderate`, `serious`, or `critical`). Override the impact defined by checks.
- `tags` - **optional** `Array` Strings of the accessibility guidelines of which the Rule applies.
- `metadata` - `Object` Consisting of:
- `description` - `String` Text string that describes what the rule does.
Expand Down Expand Up @@ -155,7 +155,7 @@ Similar to Rules, Checks are defined by JSON files in the [lib/checks directory]
- `after` - **optional** `String` The ID of the function that gets called for checks that operate on a page-level basis, to process the results from the iframes.
- `options` - **optional** `Object` Any information the Check needs that you might need to customize and/or is locale specific. Options can be overridden at runtime (with the options parameter) or config-time. For example, the [valid-lang](../lib/checks/language/valid-lang.json) Check defines what ISO 639-1 language codes it should accept as valid. Options do not need to follow any specific format or type; it is up to the author of a Check to determine the most appropriate format.
- `metadata` - `Object` Consisting of:
- `impact` - `String` (one of `minor`, `moderate`, `serious`, or `critical`)
- `impact` - **Deprecated** `String` (one of `minor`, `moderate`, `serious`, or `critical`)
- `messages` - `Object` These messages are displayed when the Check passes or fails
- `pass` - `String` [doT.js](http://olado.github.io/doT/) template string displayed when the Check passes
- `fail` - `String` [doT.js](http://olado.github.io/doT/) template string displayed when the Check fails
Expand Down
1 change: 1 addition & 0 deletions lib/rules/accesskeys.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "accesskeys",
"impact": "serious",
"selector": "[accesskey]",
"excludeHidden": false,
"tags": ["cat.keyboard", "best-practice"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/area-alt.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "area-alt",
"impact": "critical",
"selector": "map area[href]",
"excludeHidden": false,
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-allowed-attr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-allowed-attr",
"impact": "critical",
"matches": "aria-allowed-attr-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["5c01ea"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-allowed-role.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-allowed-role",
"impact": "minor",
"excludeHidden": false,
"selector": "[role]",
"matches": "aria-allowed-role-matches",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-braille-equivalent.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-braille-equivalent",
"impact": "serious",
"selector": "[aria-brailleroledescription], [aria-braillelabel]",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-command-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-command-name",
"impact": "serious",
"selector": "[role=\"link\"], [role=\"button\"], [role=\"menuitem\"]",
"matches": "no-naming-method-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-conditional-attr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-conditional-attr",
"impact": "serious",
"matches": "aria-allowed-attr-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["5c01ea"],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/aria-deprecated-role.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "aria-deprecated-role",
"impact": "minor",
"selector": "[role]",
"matches": "no-empty-role-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"impact": "minor",
"actIds": ["674b10"],
"metadata": {
"description": "Ensures elements do not use deprecated roles",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-dialog-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-dialog-name",
"impact": "serious",
"selector": "[role=\"dialog\"], [role=\"alertdialog\"]",
"matches": "no-naming-method-matches",
"tags": ["cat.aria", "best-practice"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-hidden-body.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-hidden-body",
"impact": "critical",
"selector": "body",
"excludeHidden": false,
"matches": "is-initiator-matches",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-hidden-focus.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-hidden-focus",
"impact": "serious",
"selector": "[aria-hidden=\"true\"]",
"matches": "aria-hidden-focus-matches",
"excludeHidden": false,
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-input-field-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-input-field-name",
"impact": "serious",
"selector": "[role=\"combobox\"], [role=\"listbox\"], [role=\"searchbox\"], [role=\"slider\"], [role=\"spinbutton\"], [role=\"textbox\"]",
"matches": "no-naming-method-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-meter-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-meter-name",
"impact": "serious",
"selector": "[role=\"meter\"]",
"matches": "no-naming-method-matches",
"tags": ["cat.aria", "wcag2a", "wcag111", "EN-301-549", "EN-9.1.1.1"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-progressbar-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-progressbar-name",
"impact": "serious",
"selector": "[role=\"progressbar\"]",
"matches": "no-naming-method-matches",
"tags": ["cat.aria", "wcag2a", "wcag111", "EN-301-549", "EN-9.1.1.1"],
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/aria-prohibited-attr.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "aria-prohibited-attr",
"impact": "serious",
"matches": "aria-allowed-attr-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["5c01ea"],
"impact": "serious",
"metadata": {
"description": "Ensures ARIA attributes are not prohibited for an element's role",
"help": "Elements must only use permitted ARIA attributes"
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-required-attr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-required-attr",
"impact": "critical",
"selector": "[role]",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["4e8ab6"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-required-children.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-required-children",
"impact": "critical",
"selector": "[role]",
"matches": "aria-required-children-matches",
"tags": ["cat.aria", "wcag2a", "wcag131", "EN-301-549", "EN-9.1.3.1"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-required-parent.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-required-parent",
"impact": "critical",
"selector": "[role]",
"matches": "aria-required-parent-matches",
"tags": ["cat.aria", "wcag2a", "wcag131", "EN-301-549", "EN-9.1.3.1"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-roledescription.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-roledescription",
"impact": "serious",
"selector": "[aria-roledescription]",
"tags": [
"cat.aria",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-text.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-text",
"impact": "serious",
"selector": "[role=text]",
"tags": ["cat.aria", "best-practice"],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-toggle-field-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-toggle-field-name",
"impact": "serious",
"selector": "[role=\"checkbox\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [role=\"radio\"], [role=\"switch\"], [role=\"option\"]",
"matches": "no-naming-method-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-tooltip-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-tooltip-name",
"impact": "serious",
"selector": "[role=\"tooltip\"]",
"matches": "no-naming-method-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-treeitem-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-treeitem-name",
"impact": "serious",
"selector": "[role=\"treeitem\"]",
"matches": "no-naming-method-matches",
"tags": ["cat.aria", "best-practice"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-valid-attr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "aria-valid-attr",
"impact": "critical",
"matches": "aria-has-attr-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["5f99a7"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/audio-caption.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "audio-caption",
"impact": "critical",
"selector": "audio",
"enabled": false,
"excludeHidden": false,
Expand Down
1 change: 1 addition & 0 deletions lib/rules/autocomplete-valid.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "autocomplete-valid",
"impact": "serious",
"matches": "autocomplete-matches",
"tags": [
"cat.forms",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/avoid-inline-spacing.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "avoid-inline-spacing",
"impact": "serious",
"selector": "[style]",
"matches": "is-visible-on-screen-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/blink.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "blink",
"impact": "serious",
"selector": "blink",
"excludeHidden": false,
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/button-name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "button-name",
"impact": "critical",
"selector": "button",
"matches": "no-explicit-name-required-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/bypass.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "bypass",
"impact": "serious",
"selector": "html",
"pageLevel": true,
"matches": "bypass-matches",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/color-contrast-enhanced.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "color-contrast-enhanced",
"impact": "serious",
"matches": "color-contrast-matches",
"excludeHidden": false,
"enabled": false,
Expand Down
1 change: 1 addition & 0 deletions lib/rules/color-contrast.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "color-contrast",
"impact": "serious",
"matches": "color-contrast-matches",
"excludeHidden": false,
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/css-orientation-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "css-orientation-lock",
"impact": "serious",
"selector": "html",
"tags": [
"cat.structure",
Expand Down
1 change: 1 addition & 0 deletions lib/rules/definition-list.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "definition-list",
"impact": "serious",
"selector": "dl",
"matches": "no-role-matches",
"tags": ["cat.structure", "wcag2a", "wcag131", "EN-301-549", "EN-9.1.3.1"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/dlitem.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "dlitem",
"impact": "serious",
"selector": "dd, dt",
"matches": "no-role-matches",
"tags": ["cat.structure", "wcag2a", "wcag131", "EN-301-549", "EN-9.1.3.1"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/document-title.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "document-title",
"impact": "serious",
"selector": "html",
"matches": "is-initiator-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/duplicate-id-active.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "duplicate-id-active",
"impact": "serious",
"selector": "[id]",
"matches": "duplicate-id-active-matches",
"excludeHidden": false,
Expand Down
1 change: 1 addition & 0 deletions lib/rules/duplicate-id-aria.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "duplicate-id-aria",
"impact": "critical",
"selector": "[id]",
"matches": "duplicate-id-aria-matches",
"excludeHidden": false,
Expand Down
1 change: 1 addition & 0 deletions lib/rules/duplicate-id.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "duplicate-id",
"impact": "minor",
"selector": "[id]",
"matches": "duplicate-id-misc-matches",
"excludeHidden": false,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/empty-heading.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "empty-heading",
"impact": "minor",
"selector": "h1, h2, h3, h4, h5, h6, [role=\"heading\"]",
"matches": "heading-matches",
"tags": ["cat.name-role-value", "best-practice"],
"actIds": ["ffd0e9"],
"impact": "minor",
"metadata": {
"description": "Ensures headings have discernible text",
"help": "Headings should not be empty"
Expand Down
1 change: 1 addition & 0 deletions lib/rules/empty-table-header.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "empty-table-header",
"impact": "minor",
"selector": "th:not([role]), [role=\"rowheader\"], [role=\"columnheader\"]",
"tags": ["cat.name-role-value", "best-practice"],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/focus-order-semantics.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "focus-order-semantics",
"impact": "minor",
"selector": "div, h1, h2, h3, h4, h5, h6, [role=heading], p, span",
"matches": "inserted-into-focus-order-matches",
"tags": ["cat.keyboard", "best-practice", "experimental"],
Expand Down
1 change: 1 addition & 0 deletions lib/rules/form-field-multiple-labels.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "form-field-multiple-labels",
"impact": "moderate",
"selector": "input, select, textarea",
"matches": "label-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/frame-focusable-content.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "frame-focusable-content",
"impact": "serious",
"selector": "html",
"matches": "frame-focusable-content-matches",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions lib/rules/frame-tested.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "frame-tested",
"impact": "critical",
"selector": "html, frame, iframe",
"tags": ["cat.structure", "best-practice", "review-item"],
"metadata": {
Expand Down
Loading

0 comments on commit 2cc5547

Please sign in to comment.