Skip to content

Commit

Permalink
fix: parse ruleId from loading error message (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Oct 1, 2023
1 parent f69f873 commit 95c89de
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/engine/worker-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type WorkerMessage =

// Regex used to attempt parsing out rule which caused linter to crash
const RULE_FROM_TRACE_REGEXP = /Rule: "(.*?)"/;
const RULE_FROM_LOADING_ERROR = /Error while loading rule '(.*?)'/;
const RULE_FROM_PATH_REGEXP = /rules\/(.*?)\.js/;
const UNKNOWN_RULE_ID = 'unable-to-parse-rule-id';

Expand Down Expand Up @@ -153,6 +154,8 @@ function parseErrorStack(error: Error, file: SourceFile): LintMessage {
stack.match(RULE_FROM_TRACE_REGEXP) ||
// Older ESLint versions
stack.match(RULE_FROM_PATH_REGEXP) ||
// Rule loading error
stack.match(RULE_FROM_LOADING_ERROR) ||
[];

const ruleId = ruleMatch.pop() || UNKNOWN_RULE_ID;
Expand Down

0 comments on commit 95c89de

Please sign in to comment.