Skip to content

Commit

Permalink
Fixed crash for v flag in regexp/optimal-quantifier-concatenation (#…
Browse files Browse the repository at this point in the history
…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 <mitchi5000.ms@googlemail.com>

* fix

---------

Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
  • Loading branch information
ota-meshi and RunDevelopment committed Oct 20, 2023
1 parent 669b239 commit 542c39d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilly-pumpkins-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-regexp": patch
---

Fixed crash for v flag in `regexp/optimal-quantifier-concatenation`
3 changes: 2 additions & 1 deletion lib/rules/optimal-quantifier-concatenation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ function getSingleConsumedChar(
element: Element | Alternative,
flags: ReadonlyFlags,
): SingleConsumedChar {
const empty = flags.unicode ? EMPTY_UNICODE : EMPTY_UTF16
const empty =
flags.unicode || flags.unicodeSets ? EMPTY_UNICODE : EMPTY_UTF16

switch (element.type) {
case "Alternative":
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/optimal-quantifier-concatenation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tester.run("optimal-quantifier-concatenation", rule as any, {
},
String.raw`/^(?:\[\[\[?.+?\]?\]\]|<<.+?>>)$/`,
String.raw`/a\s*?(?=\r?\n|\r)/`,
String.raw`/(?:a|b)?c/v`,
],
invalid: [
{
Expand Down

0 comments on commit 542c39d

Please sign in to comment.