Skip to content

Commit 64690a8

Browse files
committed
fix(no_invalid_regexp): support inside function calls
1 parent ac2aa57 commit 64690a8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/rules/no_invalid_regexp.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ impl<'c, 'view> NoInvalidRegexpVisitor<'c, 'view> {
8888
self.check_regex(pattern, "", range);
8989
}
9090
}
91+
self.visit_expr(callee);
92+
for arg in args {
93+
self.visit_expr(&arg.expr);
94+
}
9195
}
9296

9397
fn check_regex(&mut self, pattern: &str, flags: &str, range: SourceRange) {
@@ -193,6 +197,22 @@ let re = new RegExp('foo', x);",
193197
r"/(?<a>a)\k</": [{ col: 0, message: MESSAGE, hint: HINT }],
194198
r"/(?<!a){1}/": [{ col: 0, message: MESSAGE, hint: HINT }],
195199
r"/(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)\11/u": [{ col: 0, message: MESSAGE, hint: HINT }],
196-
}
200+
r"
201+
((_) => [
202+
/+/,
203+
RegExp('+'),
204+
new RegExp('+'),
205+
])([
206+
/+/,
207+
RegExp('+'),
208+
new RegExp('+'),
209+
]);": [
210+
{ line: 3, col: 4, message: MESSAGE, hint: HINT },
211+
{ line: 4, col: 4, message: MESSAGE, hint: HINT },
212+
{ line: 5, col: 4, message: MESSAGE, hint: HINT },
213+
{ line: 7, col: 4, message: MESSAGE, hint: HINT },
214+
{ line: 8, col: 4, message: MESSAGE, hint: HINT },
215+
{ line: 9, col: 4, message: MESSAGE, hint: HINT }
216+
]}
197217
}
198218
}

0 commit comments

Comments
 (0)