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

False positive of `regexp/no-unused-capturing-group` with `hasIndices`

sapphi-red opened this issue · comments

Information:

  • ESLint version: 8.54.0
  • eslint-plugin-regexp version: 2.1.1

Description

const re = /(foo)/d

console.log(re.exec('foo').indices[1])

https://ota-meshi.github.io/eslint-plugin-regexp/playground/#eJwVyUEKwyAQQNGryGyiUJV2KfQktYugUxFkRsYIgZC7N1l9eP+AxBkhXKGxKUH1Vl7/mI3PkSLdzA1d46IFHe6Y9HLtxbhKuSYcn+fXRIIHyGw4IBwgWHDvnthOmgOzTWvfplQqtgjPDuF1nn+8YyoG

In this case, the capture group is used by .indices[1]. But the rule reports the error.

Thank you for posting this issue.
I'll fix that.