1
- use deno_ast:: swc:: common:: comments:: { Comment , CommentKind } ;
2
- use deno_ast:: swc:: common:: { BytePos , Span , Spanned } ;
1
+ use deno_ast:: swc:: common:: comments:: Comment ;
2
+ use deno_ast:: swc:: common:: comments:: CommentKind ;
3
+ use deno_ast:: swc:: common:: BytePos ;
4
+ use deno_ast:: swc:: common:: Span ;
5
+ use deno_ast:: swc:: common:: Spanned ;
3
6
use deno_ast:: swc:: parser:: lexer:: util:: CharExt ;
4
- use deno_ast:: swc:: parser:: token:: { Token , TokenAndSpan } ;
7
+ use deno_ast:: swc:: parser:: token:: Token ;
8
+ use deno_ast:: swc:: parser:: token:: TokenAndSpan ;
5
9
use deno_ast:: view:: * ;
6
10
use deno_ast:: MediaType ;
7
11
use deno_ast:: ParsedSource ;
12
+ use dprint_core:: formatting:: condition_resolvers;
13
+ use dprint_core:: formatting:: conditions:: * ;
14
+ use dprint_core:: formatting:: ir_helpers:: * ;
8
15
use dprint_core:: formatting:: * ;
9
- use dprint_core:: formatting:: { condition_resolvers, conditions:: * , ir_helpers:: * } ;
10
16
use std:: rc:: Rc ;
11
17
12
18
use super :: sorting:: * ;
@@ -3506,28 +3512,27 @@ fn gen_string_literal<'a>(node: &'a Str, context: &mut Context<'a>) -> PrintItem
3506
3512
Node :: TsGetterSignature ( parent) => match_key_expr ( parent. key ) ,
3507
3513
Node :: TsSetterSignature ( parent) => match_key_expr ( parent. key ) ,
3508
3514
Node :: TsMethodSignature ( parent) => match_key_expr ( parent. key ) ,
3509
- _ => false
3515
+ _ => false ,
3510
3516
}
3511
3517
}
3512
3518
3513
3519
fn match_key_expr ( key : Expr ) -> bool {
3514
3520
match key {
3515
- Expr :: Lit ( Lit :: Str ( _str) ) => true ,
3516
- Expr :: Tpl ( _tpl) => true ,
3517
- _ => false
3521
+ Expr :: Lit ( Lit :: Str ( _str) ) => true ,
3522
+ Expr :: Tpl ( _tpl) => true ,
3523
+ _ => false ,
3518
3524
}
3519
3525
}
3520
3526
fn match_key_prop_name ( key : PropName ) -> bool {
3521
3527
match key {
3522
3528
PropName :: Str ( _str) => true ,
3523
- _ => false
3529
+ _ => false ,
3524
3530
}
3525
3531
}
3526
-
3527
3532
3528
3533
fn get_string_literal_text ( string_value : String , is_jsx_attribute : bool , should_remove_quotes_if_identifier : bool , context : & mut Context ) -> String {
3529
3534
if should_remove_quotes_if_identifier && is_valid_identifier ( & string_value) {
3530
- return string_value
3535
+ return string_value;
3531
3536
}
3532
3537
return if is_jsx_attribute {
3533
3538
// JSX attributes cannot contain escaped quotes so regardless of
@@ -3547,12 +3552,14 @@ fn gen_string_literal<'a>(node: &'a Str, context: &mut Context<'a>) -> PrintItem
3547
3552
} ;
3548
3553
3549
3554
fn is_valid_identifier ( string_value : & str ) -> bool {
3550
- if string_value. len ( ) == 0 { return false }
3555
+ if string_value. len ( ) == 0 {
3556
+ return false ;
3557
+ }
3551
3558
for ( i, c) in string_value. chars ( ) . enumerate ( ) {
3552
3559
if ( i == 0 && !c. is_ident_start ( ) ) || !c. is_ident_part ( ) {
3553
- return false
3560
+ return false ;
3554
3561
}
3555
- } ;
3562
+ }
3556
3563
true
3557
3564
}
3558
3565
0 commit comments