ota-meshi / eslint-plugin-regexp

ESLint plugin for finding regex mistakes and style guide violations.

Home Page:https://ota-meshi.github.io/eslint-plugin-regexp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prefer-regexp-exec don't working class property

ODGodinho opened this issue · comments

Information:

  • ESLint version: 8.29.0
  • eslint-plugin-regexp version: 1.11.0

Description
The following case reports that RegExp#exec() should be changed

    protected readonly PATH_REGEXP: RegExp = /^.*\//g;

    protected getLogPath(filepath: string): string | undefined {
        const match = filepath.match(this.PATH_REGEXP); // Eslint error: `Use the `RegExp#exec()` method instead`

        return match?.[0];
    }

Thank you for this issue.
If you are familiar with typescript's AST and API, please consider submitting a PR.