Skip to content

Commit

Permalink
fix(linter-crash): prevent displaying Rule: null when unable to par…
Browse files Browse the repository at this point in the history
…se ruleId
  • Loading branch information
AriPerkkio committed Nov 8, 2020
1 parent 74e75de commit 10c4ac9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/engine/worker-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type WorkerMessage =

// Regex used to attempt parsing out rule which caused linter to crash
const RULE_REGEXP = /rules\/(.*?)\.js/;
const UNKNOWN_RULE_ID = 'unable-to-parse-rule-id';

// Regex used to attempt parsing out line which caused linter to crash
const LINE_REGEX = /while linting <text>:(([0-9]+)?)/;
Expand Down Expand Up @@ -108,7 +109,7 @@ function parseErrorStack(error: Error, file: SourceFile): LintMessage {

const stack = error.stack || '';
const ruleMatch = stack.match(RULE_REGEXP) || [];
const ruleId = ruleMatch.pop() || null;
const ruleId = ruleMatch.pop() || UNKNOWN_RULE_ID;

const lineMatch = stack.match(LINE_REGEX) || [];
const line = parseInt(lineMatch.pop() || '0');
Expand Down

0 comments on commit 10c4ac9

Please sign in to comment.