@@ -847,6 +847,44 @@ test('estree-util-build-jsx', (t) => {
847
847
'should support skip whitespace only content'
848
848
)
849
849
850
+ t . deepEqual (
851
+ expression (
852
+ buildJsx ( parse ( [ '<a>' , ' line1' , '</a>' ] . join ( '\n' ) ) , { pragma : 'h' } )
853
+ ) ,
854
+ {
855
+ type : 'CallExpression' ,
856
+ callee : { type : 'Identifier' , name : 'h' } ,
857
+ arguments : [
858
+ { type : 'Literal' , value : 'a' } ,
859
+ { type : 'Literal' , value : null } ,
860
+ { type : 'Literal' , value : 'line1' }
861
+ ] ,
862
+ optional : false
863
+ } ,
864
+ 'should trim strings with leading line feed'
865
+ )
866
+
867
+ t . deepEqual (
868
+ expression (
869
+ buildJsx ( parse ( [ '<a>' , ' line1{" "}' , ' line2' , '</a>' ] . join ( '\n' ) ) , {
870
+ pragma : 'h'
871
+ } )
872
+ ) ,
873
+ {
874
+ type : 'CallExpression' ,
875
+ callee : { type : 'Identifier' , name : 'h' } ,
876
+ arguments : [
877
+ { type : 'Literal' , value : 'a' } ,
878
+ { type : 'Literal' , value : null } ,
879
+ { type : 'Literal' , value : 'line1' } ,
880
+ { type : 'Literal' , value : ' ' } ,
881
+ { type : 'Literal' , value : 'line2' }
882
+ ] ,
883
+ optional : false
884
+ } ,
885
+ 'should trim strings with leading line feed (multiline test)'
886
+ )
887
+
850
888
t . equal (
851
889
generate (
852
890
buildJsx ( parse ( '<>\n <a b c="d" e={f} {...g}>h</a>\n</>' ) , {
@@ -1524,7 +1562,6 @@ function parse(doc, clean, addComments) {
1524
1562
1525
1563
if ( addComments !== false ) tree . comments = comments
1526
1564
1527
- // @ts -expect-error: types are wrong.
1528
1565
if ( clean !== false ) walk ( tree , { leave} )
1529
1566
1530
1567
return JSON . parse ( JSON . stringify ( tree ) )
0 commit comments