Skip to content

Commit 07daab6

Browse files
Updated isEqual and isCovered by using regexp-ast-analysis (#177)
1 parent 2c051cd commit 07daab6

File tree

5 files changed

+212
-416
lines changed

5 files changed

+212
-416
lines changed

lib/rules/no-dupe-disjunctions.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export default createRule("no-dupe-disjunctions", {
7777
function createVisitor({
7878
node,
7979
flags,
80+
toCharSet,
8081
getRegexpLocation,
8182
}: RegExpContext): RegExpVisitor.Handlers {
8283
/** Verify group node */
@@ -94,12 +95,13 @@ export default createRule("no-dupe-disjunctions", {
9495
const dupeAlt = disallowNeverMatch
9596
? leftAlts.find((leftAlt) =>
9697
isCoveredNode(leftAlt, alt, {
97-
flags: { left: flags, right: flags },
98+
flags,
9899
canOmitRight,
100+
toCharSet,
99101
}),
100102
)
101103
: leftAlts.find((leftAlt) =>
102-
isEqualNodes(leftAlt, alt, (a, _b) => {
104+
isEqualNodes(leftAlt, alt, toCharSet, (a, _b) => {
103105
if (a.type === "CapturingGroup") {
104106
return false
105107
}
@@ -112,7 +114,7 @@ export default createRule("no-dupe-disjunctions", {
112114
loc: getRegexpLocation(alt),
113115
messageId:
114116
disallowNeverMatch &&
115-
!isEqualNodes(dupeAlt, alt)
117+
!isEqualNodes(dupeAlt, alt, toCharSet)
116118
? "neverExecute"
117119
: "duplicated",
118120
})

0 commit comments

Comments
 (0)