Skip to content

Commit c7f907f

Browse files
[pattern tests] Don't treat named capturing groups as unused
1 parent 854b1bd commit c7f907f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/pattern-tests.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ function testPatterns (getPrism, mainLanguage) {
269269
await forEachPattern(({ ast, tokenPath, lookbehindGroup, reportError }) => {
270270
forEachCapturingGroup(ast.pattern, ({ group, number }) => {
271271
const isLookbehindGroup = group === lookbehindGroup;
272-
if (group.references.length === 0 && !isLookbehindGroup) {
272+
const isNamedGroup = !!group.name; // named capturing groups are used for tokenization, so they are not unused
273+
if (group.references.length === 0 && !isLookbehindGroup && !isNamedGroup) {
273274
const fixes = [];
274275
fixes.push(
275276
`Make this group a non-capturing group ('(?:...)' instead of '(...)'). (It's usually this option.)`

0 commit comments

Comments
 (0)