Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ declare namespace axe {
matches?: string | ((node: Element, virtualNode: VirtualNode) => boolean);
reviewOnFail?: boolean;
actIds?: string[];
metadata?: Omit<RuleMetadata, 'ruleId' | 'tags' | 'actIds'>;
metadata?: Omit<RuleMetadata, 'ruleId' | 'tags' | 'actIds' | 'enabled'>;
}
interface AxePlugin {
id: string;
Expand All @@ -352,6 +352,7 @@ declare namespace axe {
helpUrl: string;
tags: string[];
actIds?: string[];
enabled: boolean;
}
interface SerialDqElement {
source: string;
Expand Down
8 changes: 5 additions & 3 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Returns a list of all rules with their ID and description

- `tags` - **optional** Array of tags used to filter returned rules. If omitted, it will return all rules. See [axe-core tags](#axe-core-tags).

**Returns:** Array of rules that match the input filter with each entry having a format of `{ruleId: <id>, description: <desc>, helpUrl: <url>, help: <help>, tags: <tags>}`
**Returns:** Array of rules that match the input filter with each entry having a format of `{ruleId: <id>, description: <desc>, helpUrl: <url>, help: <help>, tags: <tags>, enabled: <boolean>}`. `enabled` is `true` for rules that run by default when `axe.run()` is called with no options, and `false` for rules that are disabled by default.

#### Example 1

Expand All @@ -163,7 +163,8 @@ In this example, we pass in the WCAG 2 A and AA tags into `axe.getRules` to retr
"section508",
"section508.22.a"
],
actIds: ['c487ae']
actIds: ['c487ae'],
enabled: true
},
{
description: "Ensure ARIA attributes are allowed for an element's role",
Expand All @@ -174,7 +175,8 @@ In this example, we pass in the WCAG 2 A and AA tags into `axe.getRules` to retr
"cat.aria",
"wcag2a",
"wcag412"
]
],
enabled: true
}
…
]
Expand Down
3 changes: 2 additions & 1 deletion lib/core/public/get-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function getRules(tags) {
help: rd.help,
helpUrl: rd.helpUrl,
tags: matchingRule.tags,
actIds: matchingRule.actIds
actIds: matchingRule.actIds,
enabled: matchingRule.enabled
};
});
}
Expand Down
10 changes: 9 additions & 1 deletion test/core/public/get-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('axe.getRules', () => {
id: 'awesomeRule2',
any: [],
tags: ['tag1', 'tag2'],
actIds: ['abc123', 'xyz789']
actIds: ['abc123', 'xyz789'],
enabled: false
}
],
data: {
Expand Down Expand Up @@ -103,6 +104,13 @@ describe('axe.getRules', () => {
assert.deepEqual(retValue[1].actIds, ['abc123', 'xyz789']);
});

it('should return the enabled state of each rule', () => {
const retValue = axe.getRules();
assert.lengthOf(retValue, 2);
assert.equal(retValue[0].enabled, true);
assert.equal(retValue[1].enabled, false);
});

it('should return all rules if given empty array', () => {
const retValue = axe.getRules([]);
assert.equal(retValue[0].ruleId, 'awesomeRule1');
Expand Down
Loading