Add option to rule `no-unused-capturing-group` to allow unused named capturing groups
pkerschbaum opened this issue · comments
Motivation
I have this regex:
const REGEX_SEMANTIC_VERSION = /(?<majorVersion>\d+)\.(?<minorVersion>\d+)\.(?<patchVersion>\d+)(?:-(?<suffix>.+))?/;
The named capturing groups makes it clear what part of the regex is what.
Currently I don't access these capturing groups, so no-unused-capturing-group
reports this as an error.
Feature Request
Add an option to no-unused-capturing-group
so that it does not report unused named capturing groups.
Why there is no "named non-capturing group“ in JS 😄
I'm waiting for the day we finally get the x
flag and (?#comment)
groups in JS.
As for (?<comment>...)
, I'm not sure. I don't think that using named capturing groups for comments is a good idea. Of course, you used well-chosen names, so I don't think it would be bad to allow this usage of names.