forked from dequelabs/axe-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-check-option.js
More file actions
41 lines (36 loc) · 1.17 KB
/
get-check-option.js
File metadata and controls
41 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Determines which CheckOption to use, either defined on the rule options, global check options or the check itself
* @param {Check} check The Check object
* @param {String} ruleID The ID of the rule
* @param {Object} options Options object as passed to main API
* @return {Object} The resolved object with `options` and `enabled` keys
*/
function getCheckOption(check, ruleID, options) {
const ruleCheckOption = (((options.rules && options.rules[ruleID]) || {})
.checks || {})[check.id];
const checkOption = (options.checks || {})[check.id];
let enabled = check.enabled;
let opts = check.options;
if (checkOption) {
if (checkOption.hasOwnProperty('enabled')) {
enabled = checkOption.enabled;
}
if (checkOption.hasOwnProperty('options')) {
opts = checkOption.options;
}
}
if (ruleCheckOption) {
if (ruleCheckOption.hasOwnProperty('enabled')) {
enabled = ruleCheckOption.enabled;
}
if (ruleCheckOption.hasOwnProperty('options')) {
opts = ruleCheckOption.options;
}
}
return {
enabled: enabled,
options: opts,
absolutePaths: options.absolutePaths
};
}
export default getCheckOption;