Skip to content

Commit

Permalink
fix(typings): add proper return value to getRule (#1900)
Browse files Browse the repository at this point in the history
* chore: add GetRuleResult interface for getRule function

* chore: fix axe core typing test
  • Loading branch information
michael-siek authored Nov 14, 2019
1 parent a550309 commit 4d907f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ declare namespace axe {
}[];
cleanup?(callback: Function): void;
}
interface RuleMetadata {
ruleId: string;
description: string;
help: string;
helpUrl: string;
tags: string[];
}

let plugins: any;

Expand Down Expand Up @@ -203,7 +210,7 @@ declare namespace axe {
* @param {Array} tags Optional array of tags
* @return {Array} Array of rules
*/
function getRules(tags?: string[]): Object[];
function getRules(tags?: string[]): RuleMetadata[];

/**
* Restores the default axe configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
| role-img-alt | Ensures [role='img'] elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | true | false |
| scope-attr-valid | Ensures the scope attribute is used correctly on tables | Moderate, Critical | cat.tables, best-practice | true | true | false |
| scrollable-region-focusable | Elements that have scrollable content should be accessible by keyboard | Moderate | wcag2a, wcag211 | true | true | false |
| server-side-image-map | Ensures that server-side image maps are not used | Minor | cat.text-alternatives, wcag2a, wcag211, section508, section508.22.f | true | true | false |
| server-side-image-map | Ensures that server-side image maps are not used | Minor | cat.text-alternatives, wcag2a, wcag211, section508, section508.22.f | true | false | true |
| skip-link | Ensure all skip links have a focusable target | Moderate | cat.keyboard, best-practice | true | true | true |
| tabindex | Ensures tabindex attribute values are not greater than 0 | Serious | cat.keyboard, best-practice | true | true | false |
| table-duplicate-name | Ensure that tables do not have the same summary and caption | Minor | cat.tables, best-practice | true | true | false |
Expand Down
5 changes: 5 additions & 0 deletions typings/axe-core/axe-core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ axe.reset();
axe.getRules(['wcag2aa']);
typeof axe.getRules() === 'object';

const rules = axe.getRules();
rules.forEach(rule => {
rule.ruleId.substr(1234);
});

// Plugins
var pluginSrc: axe.AxePlugin = {
id: 'doStuff',
Expand Down

0 comments on commit 4d907f8

Please sign in to comment.