eslint-plugin-optimize-regex
eslint-plugin-optimize-regex copied to clipboard
False-positive that produces invalid regular expression
/\]/u
is getting optimized to /]/u
which produces Parsing error: Invalid regular expression: /]/: Lone quantifier brackets
.
Same issue, /\{.*\}/u.exec("abc{foo}xyz")
is optimized to /{.*}/u.exec("abc{foo}xyz")
which produces Uncaught SyntaxError: Invalid regular expression: /{.*}/: Lone quantifier brackets
.
The u
flag disables Annex B extension, and makes regex behave like strict mode.
I noticed this problem because require-unicode-regexp recommended u
to me.
Please report this issue to the upstream library https://github.com/DmitrySoshnikov/regexp-tree
Upstream issue: https://github.com/DmitrySoshnikov/regexp-tree/issues/224.
Great! Once it's fixed, I will be happy to publish an update that includes the fix