Skip to content

Commit

Permalink
fix(no_invalid_regexp): support inside function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Colt45s committed Jul 28, 2024
1 parent ac2aa57 commit 05f713d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/rules/no_invalid_regexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ impl<'c, 'view> NoInvalidRegexpVisitor<'c, 'view> {
self.check_regex(pattern, "", range);
}
}
self.visit_expr(callee);
for arg in args {
self.visit_expr(&arg.expr);
}
}

fn check_regex(&mut self, pattern: &str, flags: &str, range: SourceRange) {
Expand Down Expand Up @@ -193,6 +197,22 @@ let re = new RegExp('foo', x);",
r"/(?<a>a)\k</": [{ col: 0, message: MESSAGE, hint: HINT }],
r"/(?<!a){1}/": [{ col: 0, message: MESSAGE, hint: HINT }],
r"/(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)\11/u": [{ col: 0, message: MESSAGE, hint: HINT }],
}
r"
((_) => [
/+/,
RegExp('+'),
new RegExp('+'),
])([
/+/,
RegExp('+'),
new RegExp('+'),
]);": [
{ line: 3, col: 4, message: MESSAGE, hint: HINT },
{ line: 4, col: 4, message: MESSAGE, hint: HINT },
{ line: 5, col: 4, message: MESSAGE, hint: HINT },
{ line: 7, col: 4, message: MESSAGE, hint: HINT },
{ line: 8, col: 4, message: MESSAGE, hint: HINT },
{ line: 9, col: 4, message: MESSAGE, hint: HINT }
]}
}
}

0 comments on commit 05f713d

Please sign in to comment.