-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ignore flag/config was not applied
- Loading branch information
Showing
5 changed files
with
58 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
import type { RuleSetType } from '../rules/rules' | ||
import { RULES } from '../rules/rules' | ||
|
||
export function groupRulesByRuleset(appliedRules: string[]): { rulesets: RuleSetType[], individualRules: string[] } { | ||
export function groupRulesByRuleset(apply: string[]): { rulesets: RuleSetType[], individualRules: string[] } { | ||
const rulesets: RuleSetType[] = [] | ||
const individualRules: string[] = [] | ||
|
||
// Iterate through each ruleset and its associated rules | ||
Object.entries(RULES).forEach(([ruleset, rules]) => { | ||
// if the ruleset can be found in apply, add it to rulesets | ||
if (apply.includes(ruleset)) { | ||
rulesets.push(ruleset as RuleSetType) | ||
individualRules.push(...rules) | ||
return | ||
} | ||
|
||
// Check if all rules in the current ruleset are applied | ||
if (rules.every(rule => appliedRules.includes(rule))) { | ||
if (rules.every(rule => apply.includes(rule))) { | ||
// If so, add the entire ruleset | ||
rulesets.push(ruleset as RuleSetType) | ||
individualRules.push(...rules) | ||
return | ||
} | ||
else { | ||
// Otherwise, find individual rules that are applied | ||
const appliedRulesInSet = rules.filter(rule => appliedRules.includes(rule)) | ||
// Add these individual rules to the list | ||
individualRules.push(...appliedRulesInSet) | ||
} | ||
|
||
// Otherwise, find individual rules that are applied | ||
const appliedRulesInSet = rules.filter(rule => apply.includes(rule)) | ||
// Add these individual rules to the list | ||
individualRules.push(...appliedRulesInSet) | ||
}) | ||
|
||
return { rulesets, individualRules } | ||
} | ||
return { rulesets: rulesets.sort(), individualRules: individualRules.sort() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters