@@ -142,7 +142,11 @@ ruleTester.run("no-useless-backreference", rule, {
142142 String . raw `new RegExp('\\1(a)\\2', 'ug')` , // \1 would be an error, but \2 is syntax error because of the 'u' flag
143143 String . raw `const flags = 'gus'; RegExp('\\1(a){', flags);` , // \1 would be an error, but the rule is aware of the 'u' flag so this is a syntax error
144144 String . raw `RegExp('\\1(a)\\k<foo>', 'u')` , // \1 would be an error, but \k<foo> produces syntax error because of the u flag
145- String . raw `new RegExp('\\k<foo>(?<foo>a)\\k<bar>')` // \k<foo> would be an error, but \k<bar> produces syntax error because group <bar> doesn't exist
145+ String . raw `new RegExp('\\k<foo>(?<foo>a)\\k<bar>')` , // \k<foo> would be an error, but \k<bar> produces syntax error because group <bar> doesn't exist
146+
147+ // ES2024
148+ String . raw `new RegExp('([[A--B]])\\1', 'v')` ,
149+ String . raw `new RegExp('[[]\\1](a)', 'v')` // SyntaxError
146150 ] ,
147151
148152 invalid : [
@@ -508,6 +512,13 @@ ruleTester.run("no-useless-backreference", rule, {
508512 {
509513 code : String . raw `const r = RegExp, p = '\\1', s = '(a)'; new r(p + s);` ,
510514 errors : [ { messageId : "forward" , data : { bref : String . raw `\1` , group : String . raw `(a)` } , type : "NewExpression" } ]
515+ } ,
516+
517+
518+ // ES2024
519+ {
520+ code : String . raw `new RegExp('\\1([[A--B]])', 'v')` ,
521+ errors : [ { messageId : "forward" , data : { bref : String . raw `\1` , group : String . raw `([[A--B]])` } , type : "NewExpression" } ]
511522 }
512523 ]
513524} ) ;
0 commit comments