You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation
While developing #282, I noticed that ESLint's no-invalid-regexp only validates expression of the form RegExp(<string literal>). It doesn't support the concatenation of string literals and all the fancy stuff #282 can do.
E.g. ESLint's no-invalid-regexp will detect RegExp("([") but it can't detect RegExp("([" + ""). We can detect this, so why not report it?
Description
Add a new rule regexp/no-invalid-regexp that behaves like ESLint no-invalid-regexp but uses PatternSource under the hood.
The best way to implement this might be to extend the defineRegexpVisitor to allow a new visitor type that doesn't require a parsed RegExpp AST.
Examples
/* ✓ GOOD */varfoo=RegExp("foo")varfoo=RegExp("(["+"])")/* ✗ BAD */varfoo=RegExp("([")varfoo=newRegExp("(["+"\\"+"])","i")
The text was updated successfully, but these errors were encountered:
Motivation
While developing #282, I noticed that ESLint's
no-invalid-regexp
only validates expression of the formRegExp(<string literal>)
. It doesn't support the concatenation of string literals and all the fancy stuff #282 can do.E.g. ESLint's
no-invalid-regexp
will detectRegExp("([")
but it can't detectRegExp("([" + "")
. We can detect this, so why not report it?Description
Add a new rule
regexp/no-invalid-regexp
that behaves like ESLintno-invalid-regexp
but usesPatternSource
under the hood.The best way to implement this might be to extend the
defineRegexpVisitor
to allow a new visitor type that doesn't require a parsed RegExpp AST.Examples
The text was updated successfully, but these errors were encountered: