Skip to content

Commit 542c39d

Browse files
Fixed crash for v flag in regexp/optimal-quantifier-concatenation (#660)
* fix: crash for v flag in `regexp/optimal-quantifier-concatenation` * Create chilly-pumpkins-raise.md * Update lib/rules/optimal-quantifier-concatenation.ts Co-authored-by: Michael Schmidt <[email protected]> * fix --------- Co-authored-by: Michael Schmidt <[email protected]>
1 parent 669b239 commit 542c39d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.changeset/chilly-pumpkins-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-regexp": patch
3+
---
4+
5+
Fixed crash for v flag in `regexp/optimal-quantifier-concatenation`

lib/rules/optimal-quantifier-concatenation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function getSingleConsumedChar(
6464
element: Element | Alternative,
6565
flags: ReadonlyFlags,
6666
): SingleConsumedChar {
67-
const empty = flags.unicode ? EMPTY_UNICODE : EMPTY_UTF16
67+
const empty =
68+
flags.unicode || flags.unicodeSets ? EMPTY_UNICODE : EMPTY_UTF16
6869

6970
switch (element.type) {
7071
case "Alternative":

tests/lib/rules/optimal-quantifier-concatenation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tester.run("optimal-quantifier-concatenation", rule as any, {
2525
},
2626
String.raw`/^(?:\[\[\[?.+?\]?\]\]|<<.+?>>)$/`,
2727
String.raw`/a\s*?(?=\r?\n|\r)/`,
28+
String.raw`/(?:a|b)?c/v`,
2829
],
2930
invalid: [
3031
{

0 commit comments

Comments
 (0)