@@ -127,11 +127,12 @@ export namespace RegExpValidator {
127127 strict ?: boolean
128128
129129 /**
130- * ECMAScript version. Default is `2020 `.
130+ * ECMAScript version. Default is `2022 `.
131131 * - `2015` added `u` and `y` flags.
132132 * - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
133133 * and Unicode Property Escape.
134134 * - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
135+ * - `2022` added `d` flag.
135136 */
136137 ecmaVersion ?: EcmaVersion
137138
@@ -158,6 +159,7 @@ export namespace RegExpValidator {
158159 * @param unicode `u` flag.
159160 * @param sticky `y` flag.
160161 * @param dotAll `s` flag.
162+ * @param hasIndices `d` flag.
161163 */
162164 onFlags ?(
163165 start : number ,
@@ -168,6 +170,7 @@ export namespace RegExpValidator {
168170 unicode : boolean ,
169171 sticky : boolean ,
170172 dotAll : boolean ,
173+ hasIndices : boolean ,
171174 ) : void
172175
173176 /**
@@ -476,6 +479,7 @@ export class RegExpValidator {
476479 let sticky = false
477480 let unicode = false
478481 let dotAll = false
482+ let hasIndices = false
479483 for ( let i = start ; i < end ; ++ i ) {
480484 const flag = source . charCodeAt ( i )
481485
@@ -496,6 +500,8 @@ export class RegExpValidator {
496500 sticky = true
497501 } else if ( flag === LatinSmallLetterS && this . ecmaVersion >= 2018 ) {
498502 dotAll = true
503+ } else if ( flag === LatinSmallLetterD && this . ecmaVersion >= 2022 ) {
504+ hasIndices = true
499505 } else {
500506 this . raise ( `Invalid flag '${ source [ i ] } '` )
501507 }
@@ -509,6 +515,7 @@ export class RegExpValidator {
509515 unicode ,
510516 sticky ,
511517 dotAll ,
518+ hasIndices ,
512519 )
513520 }
514521
@@ -548,7 +555,7 @@ export class RegExpValidator {
548555 }
549556
550557 private get ecmaVersion ( ) {
551- return this . _options . ecmaVersion || 2020
558+ return this . _options . ecmaVersion || 2022
552559 }
553560
554561 private onLiteralEnter ( start : number ) : void {
@@ -572,6 +579,7 @@ export class RegExpValidator {
572579 unicode : boolean ,
573580 sticky : boolean ,
574581 dotAll : boolean ,
582+ hasIndices : boolean ,
575583 ) : void {
576584 if ( this . _options . onFlags ) {
577585 this . _options . onFlags (
@@ -583,6 +591,7 @@ export class RegExpValidator {
583591 unicode ,
584592 sticky ,
585593 dotAll ,
594+ hasIndices ,
586595 )
587596 }
588597 }
0 commit comments