Skip to content

Commit

Permalink
fix: d should be invalid in ES2021 (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Oct 28, 2024
1 parent 347b151 commit c4852c9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,7 @@ export class RegExpValidator {
validFlags.add(LATIN_SMALL_LETTER_Y)
if (this.ecmaVersion >= 2018) {
validFlags.add(LATIN_SMALL_LETTER_S)
if (this.ecmaVersion >= 2021) {
if (this.ecmaVersion >= 2022) {
validFlags.add(LATIN_SMALL_LETTER_D)
if (this.ecmaVersion >= 2024) {
validFlags.add(LATIN_SMALL_LETTER_V)
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/parser/literal/flags-invalid-2017.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"options": {
"strict": true,
"ecmaVersion": 2017
},
"patterns": {
"/./s": {
"error": {
"message": "Invalid regular expression: /./s: Invalid flag 's'",
"index": 3
}
}
}
}
14 changes: 14 additions & 0 deletions test/fixtures/parser/literal/flags-invalid-2021.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"options": {
"strict": true,
"ecmaVersion": 2021
},
"patterns": {
"/./d": {
"error": {
"message": "Invalid regular expression: /./d: Invalid flag 'd'",
"index": 3
}
}
}
}
14 changes: 14 additions & 0 deletions test/fixtures/parser/literal/flags-invalid-2023.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"options": {
"strict": true,
"ecmaVersion": 2023
},
"patterns": {
"/./v": {
"error": {
"message": "Invalid regular expression: /./v: Invalid flag 'v'",
"index": 3
}
}
}
}
20 changes: 20 additions & 0 deletions test/fixtures/parser/literal/flags-invalid-5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"options": {
"strict": true,
"ecmaVersion": 5
},
"patterns": {
"/./u": {
"error": {
"message": "Invalid regular expression: /./u: Invalid flag 'u'",
"index": 3
}
},
"/./y": {
"error": {
"message": "Invalid regular expression: /./y: Invalid flag 'y'",
"index": 3
}
}
}
}

0 comments on commit c4852c9

Please sign in to comment.