1
0
Fork 0

lint: simplify rule selector logic

This commit is contained in:
ssube 2019-11-15 21:14:28 -06:00 committed by Sean Sube
parent 66ca5efa75
commit ae6c3b28e0
1 changed files with 20 additions and 14 deletions

View File

@ -174,29 +174,35 @@ export async function resolveRules(rules: Array<Rule>, selector: RuleSelector):
const activeRules = new Set<Rule>();
for (const r of rules) {
if (selector.excludeLevel.includes(r.level)) {
continue;
}
if (selector.excludeName.includes(r.name)) {
continue;
}
const excludedTags = intersection(selector.excludeTag, r.tags);
if (excludedTags.length > 0) {
continue;
}
let active = false;
if (selector.includeLevel.includes(r.level)) {
activeRules.add(r);
active = true;
}
if (selector.includeName.includes(r.name)) {
activeRules.add(r);
active = true;
}
const includedTags = intersection(selector.includeTag, r.tags);
if (includedTags.length > 0) {
active = true;
}
if (selector.excludeLevel.includes(r.level)) {
active = false;
}
if (selector.excludeName.includes(r.name)) {
active = false;
}
const excludedTags = intersection(selector.excludeTag, r.tags);
if (excludedTags.length > 0) {
active = false;
}
if (active) {
activeRules.add(r);
}
}