Skip to content

[prefer-regexp-exec] The rule seems to be wrong #2280

@orgads

Description

@orgads

Repro

{
  "rules": {
    "@typescript-eslint/prefer-regexp-exec": "error"
  }
}
'foo'.match(/oo/)

Expected Result
It should not report any error.

Actual Result
It claims that Regexp.exec() is preferred.

Additional Info
The rule was requested in #283.

The rule itself looks wrong. The documentation has a link to Stack Overflow, with a quote I couldn't find in this answer. Actually the word "fast" doesn't appear in this page at all.

Performance tests from several other questions don't show any significant improvements for one over the other.

It's unclear where the impression of performance difference came from.

Versions

package version
@typescript-eslint/eslint-plugin 3.6.0
@typescript-eslint/parser 3.6.0
TypeScript 3.9.6
ESLint 7.4.0
node 12.18.0
npm 6.14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationDocumentation ("docs") that needs adding/updatingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions