11#![ allow( clippy:: redundant_allocation) ]
22
3+ use crate :: transformations:: lowercase_attrs:: requires_lowercasing;
4+ use crate :: transformations:: parse_vnode_flag:: parse_vnode_flag;
5+ use crate :: transformations:: transform_attribute:: transform_attribute;
6+ use crate :: VNodeType :: Component ;
7+ use crate :: {
8+ inferno_flags:: { ChildFlags , VNodeFlags } ,
9+ refresh:: options:: { deserialize_refresh, RefreshOptions } ,
10+ } ;
311use serde:: { Deserialize , Serialize } ;
412use std:: { borrow:: Cow , sync:: Arc } ;
513use swc_config:: merge:: Merge ;
614use swc_core:: common:: comments:: Comments ;
715use swc_core:: common:: iter:: IdentifyLast ;
816use swc_core:: common:: util:: take:: Take ;
9- use swc_core:: common:: { FileName , Mark , SourceMap , Span , Spanned , DUMMY_SP , SyntaxContext } ;
17+ use swc_core:: common:: { FileName , Mark , SourceMap , Span , Spanned , SyntaxContext , DUMMY_SP } ;
1018use swc_core:: ecma:: ast:: * ;
11- use swc_core:: ecma:: atoms:: { Atom } ;
19+ use swc_core:: ecma:: atoms:: Atom ;
1220use swc_core:: ecma:: utils:: { drop_span, prepend_stmt, quote_ident, ExprFactory , StmtLike } ;
1321use swc_core:: ecma:: visit:: { noop_visit_mut_type, visit_mut_pass, VisitMut , VisitMutWith } ;
1422use swc_core:: plugin:: errors:: HANDLER ;
1523use swc_ecma_parser:: { parse_file_as_expr, Syntax } ;
16- use crate :: VNodeType :: Component ;
17- use crate :: {
18- inferno_flags:: { ChildFlags , VNodeFlags } ,
19- refresh:: options:: { deserialize_refresh, RefreshOptions } ,
20- } ;
21- use crate :: transformations:: transform_attribute:: transform_attribute;
22- use crate :: transformations:: lowercase_attrs:: requires_lowercasing;
23- use crate :: transformations:: parse_vnode_flag:: parse_vnode_flag;
2424
2525#[ cfg( test) ]
2626mod tests;
@@ -57,7 +57,7 @@ pub fn parse_expr_for_jsx(
5757) -> Arc < Box < Expr > > {
5858 let fm = cm. new_source_file (
5959 FileName :: Custom ( format ! ( "<jsx-config-{name}.js>" ) ) . into ( ) ,
60- src
60+ src,
6161 ) ;
6262
6363 parse_file_as_expr (
@@ -402,7 +402,11 @@ where
402402 if ident. sym == "Fragment" {
403403 vnode_kind = VNodeType :: Fragment ;
404404 mut_flags = VNodeFlags :: ComponentUnknown as u16 ;
405- name_expr = Expr :: Ident ( Ident :: new ( "createFragment" . into ( ) , ident. span , Default :: default ( ) ) ) ;
405+ name_expr = Expr :: Ident ( Ident :: new (
406+ "createFragment" . into ( ) ,
407+ ident. span ,
408+ Default :: default ( ) ,
409+ ) ) ;
406410 } else {
407411 vnode_kind = Component ;
408412 mut_flags = VNodeFlags :: ComponentUnknown as u16 ;
@@ -505,7 +509,7 @@ where
505509 KeyValueProp {
506510 key : PropName :: Ident ( IdentName :: new (
507511 "onDblClick" . into ( ) ,
508- span
512+ span,
509513 ) ) ,
510514 value : match attr. value {
511515 Some ( v) => jsx_attr_value_to_expr ( v)
@@ -661,7 +665,7 @@ where
661665 let converted_prop_name = if requires_lowercasing ( & i. sym ) {
662666 PropName :: Ident ( IdentName {
663667 span : i. span ,
664- sym : i. sym . to_lowercase ( ) . into ( )
668+ sym : i. sym . to_lowercase ( ) . into ( ) ,
665669 } )
666670 } else {
667671 let converted_sym = transform_attribute ( & i. sym ) ;
@@ -675,7 +679,7 @@ where
675679 } else {
676680 PropName :: Ident ( IdentName {
677681 span : i. span ,
678- sym : converted_sym. into ( )
682+ sym : converted_sym. into ( ) ,
679683 } )
680684 }
681685 } ;
@@ -818,7 +822,8 @@ where
818822 spread : None ,
819823 expr : Box :: new ( Expr :: Call ( CallExpr {
820824 span : DUMMY_SP ,
821- ctxt : SyntaxContext :: empty ( ) . apply_mark ( self . unresolved_mark ) ,
825+ ctxt : SyntaxContext :: empty ( )
826+ . apply_mark ( self . unresolved_mark ) ,
822827 callee : self
823828 . import_create_text_vnode
824829 . get_or_insert_with ( || {
0 commit comments