Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
orgads opened this issue Jul 7, 2020 · 1 comment · Fixed by #3392
Closed

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

orgads opened this issue Jul 7, 2020 · 1 comment · Fixed by #3392
Labels
documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@orgads
Copy link

orgads commented Jul 7, 2020

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
@orgads orgads added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jul 7, 2020
@bradzacher
Copy link
Member

Unsure exactly. People requested the rule, people; people implemented the rule.

If there's now no clear perf benefit as the engines have evolved, then the docs probably need to be updated, though there's nothing "wrong" with the rule.

The rule has always primarily existed to enforce consistency within the codebase, which it still does today.

Happy to accept a PR if you want to update the rules docs.

@bradzacher bradzacher added documentation Documentation ("docs") that needs adding/updating and removed triage Waiting for team members to take a look labels Jul 7, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants