@@ -3,7 +3,7 @@ use std::borrow::Cow;
33use oxc_ast:: {
44 AstKind ,
55 ast:: {
6- CallExpression , Expression , ImportDeclaration , ImportDeclarationSpecifier , TemplateLiteral ,
6+ CallExpression , Expression , ImportDeclaration , ImportDeclarationSpecifier ,
77 match_member_expression,
88 } ,
99} ;
@@ -271,8 +271,10 @@ pub fn get_node_name_vec<'a>(expr: &'a Expression<'a>) -> Vec<Cow<'a, str>> {
271271 Expression :: StringLiteral ( string_literal) => {
272272 chain. push ( Cow :: Borrowed ( & string_literal. value ) ) ;
273273 }
274- Expression :: TemplateLiteral ( template_literal) if is_pure_string ( template_literal) => {
275- chain. push ( Cow :: Borrowed ( template_literal. quasi ( ) . unwrap ( ) . as_str ( ) ) ) ;
274+ Expression :: TemplateLiteral ( template_literal) => {
275+ if let Some ( quasi) = template_literal. quasi ( ) {
276+ chain. push ( Cow :: Borrowed ( quasi. as_str ( ) ) ) ;
277+ }
276278 }
277279 Expression :: TaggedTemplateExpression ( tagged_expr) => {
278280 chain. extend ( get_node_name_vec ( & tagged_expr. tag ) ) ;
@@ -294,10 +296,6 @@ pub fn get_node_name_vec<'a>(expr: &'a Expression<'a>) -> Vec<Cow<'a, str>> {
294296 chain
295297}
296298
297- fn is_pure_string ( template_literal : & TemplateLiteral ) -> bool {
298- template_literal. expressions . is_empty ( ) && template_literal. quasis . len ( ) == 1
299- }
300-
301299pub fn is_equality_matcher ( matcher : & KnownMemberExpressionProperty ) -> bool {
302300 matcher. is_name_equal ( "toBe" )
303301 || matcher. is_name_equal ( "toEqual" )
0 commit comments