Skip to content

Commit

Permalink
fix(eslint): handle severity and options in loadPluginRules
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jul 29, 2024
1 parent 9251d4b commit 69cde0c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/eslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ export async function loadPluginRules(
const plugins: Record<string, {
rules: Record<string, ESLint.Rule.RuleModule>;
}> = {};
for (const [rule, severity] of Object.entries(rulesConfig)) {
for (const [rule, severityOrOptions] of Object.entries(rulesConfig)) {
let severity: string;
let options: any[];
if (typeof severityOrOptions === 'string') {
severity = severityOrOptions;
options = [];
}
else {
[severity, ...options] = severityOrOptions;
}
if (severity === 'off') {
continue;
}
Expand All @@ -52,7 +61,7 @@ export async function loadPluginRules(
const ruleModule = plugin.rules[ruleName];
rules[rule] = convertRule(
ruleModule,
ruleOptions?.[ruleName] ?? [],
ruleOptions?.[ruleName] ?? options,
severity === 'error' ? 1 : 2
);
}
Expand Down

0 comments on commit 69cde0c

Please sign in to comment.