Rule proposal: Prefer RegExp#exec()
over String#match()
#283
Labels
enhancement: new plugin rule
New rule request for eslint-plugin
has pr
there is a PR raised to close this
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Those methods return identical result for regexes without the
g
flag.From
String#match
on MDN:I would like to enforce the use of
RegExp#exec
insteadString#match
for consistency when there's nog
flag in the regex, and because it's faster:This rule was originally proposed for inclusion in ESLint, but it was eventually declined for ambiguity reasons because of lack type knowledge. Lack of type knowledge is luckily not a problem here.
The text was updated successfully, but these errors were encountered: