Skip to content

Commit d0b90a9

Browse files
authored
Improve regexp/strict rule to ignore patterns with v flag (#591)
1 parent 6ad5f73 commit d0b90a9

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.changeset/clever-jobs-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-regexp": minor
3+
---
4+
5+
Improve `regexp/strict` rule to ignore patterns with v flag

lib/rules/strict.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default createRule("strict", {
8888
const { node, flags, pattern, getRegexpLocation, fixReplaceNode } =
8989
regexpContext
9090

91-
if (flags.unicode) {
91+
if (flags.unicode || flags.unicodeSets) {
9292
// the Unicode flag enables strict parsing mode automatically
9393
return {}
9494
}

tests/lib/rules/strict.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import rule from "../../../lib/rules/strict"
33

44
const tester = new RuleTester({
55
parserOptions: {
6-
ecmaVersion: 2020,
6+
ecmaVersion: "latest",
77
sourceType: "module",
88
},
99
})
@@ -22,6 +22,7 @@ tester.run("strict", rule as any, {
2222
String.raw`/[\( \) \[ \] \{ \} \| \* \+ \? \^ \$ \\ \/ \. \-]/`,
2323
"/\\u000f/",
2424
"/\\x000f/",
25+
String.raw`/[A--B]/v`,
2526
],
2627
invalid: [
2728
// source characters

0 commit comments

Comments
 (0)