Skip to content

Commit b489266

Browse files
authored
Fix false positives for disallowNeverMatch in regexp/no-dupe-disjunctions (#116)
1 parent 50698bc commit b489266

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/utils/regexp-ast/is-covered.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,8 @@ function isCoveredAltNodes(
787787
rightNodes: NormalizedNode[],
788788
options: Options,
789789
): boolean {
790-
const left = options.canOmitRight ? omitEnds(leftNodes) : leftNodes
791-
const right = options.canOmitRight ? omitEnds(rightNodes) : rightNodes
790+
const left = options.canOmitRight ? omitEnds(leftNodes) : [...leftNodes]
791+
const right = options.canOmitRight ? omitEnds(rightNodes) : [...rightNodes]
792792
while (left.length && right.length) {
793793
const le = left.shift()!
794794
const re = right.shift()!

tests/lib/rules/no-dupe-disjunctions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ tester.run("no-dupe-disjunctions", rule as any, {
3333
`/(?:(a)|(a))/`,
3434
`/(?:a|ab)/`,
3535
`/(?:.|a|b)/`,
36+
{
37+
code: `/<("[^"]*"|'[^']*'|[^'">])*>/g`,
38+
options: [{ disallowNeverMatch: true }],
39+
},
3640
],
3741
invalid: [
3842
...[

0 commit comments

Comments
 (0)