Fix linter: global state left on the regex causes problems

This commit is contained in:
Scott Nonnenberg 2020-09-11 12:36:20 -07:00 committed by Josh Perez
parent ceaf7863e1
commit 7ee6584d8b
2 changed files with 368 additions and 0 deletions

View file

@ -338,9 +338,14 @@ forEach(allSourceFiles, file => {
forEach(lines, (rawLine, lineIndex) => {
const line = rawLine.replace(/\r/g, '');
if (!rule.regex.test(line)) {
return;
}
// recreate this rule since it has g flag, and carries local state
if (rule.expression) {
rule.regex = new RegExp(rule.expression, 'g');
}
const path = relativePath;
const lineNumber = lineIndex + 1;