@@ -71,6 +71,8 @@ module.exports = function(file, api, options) {
71
71
}
72
72
73
73
const reactPath = reactPaths . paths ( ) [ 0 ] ;
74
+ // Reuse the node so that we can preserve quoting style.
75
+ const reactLiteral = reactPath . value . source ;
74
76
75
77
const isDefaultImport = reactPath . value . specifiers . some (
76
78
specifier =>
@@ -276,12 +278,12 @@ module.exports = function(file, api, options) {
276
278
277
279
if ( regularImports . length > 0 ) {
278
280
j ( reactPath ) . insertAfter (
279
- j . importDeclaration ( regularImports , j . literal ( 'react' ) ) ,
281
+ j . importDeclaration ( regularImports , reactLiteral ) ,
280
282
) ;
281
283
}
282
284
if ( typeImports . length > 0 ) {
283
285
j ( reactPath ) . insertAfter (
284
- j . importDeclaration ( typeImports , j . literal ( 'react' ) , 'type' ) ,
286
+ j . importDeclaration ( typeImports , reactLiteral , 'type' ) ,
285
287
) ;
286
288
}
287
289
@@ -301,7 +303,7 @@ module.exports = function(file, api, options) {
301
303
j ( path ) . insertAfter (
302
304
j . importDeclaration (
303
305
[ j . importDefaultSpecifier ( j . identifier ( 'React' ) ) ] ,
304
- j . literal ( 'react' ) ,
306
+ reactLiteral ,
305
307
'type' ,
306
308
) ,
307
309
) ;
@@ -326,7 +328,7 @@ module.exports = function(file, api, options) {
326
328
j ( reactPath ) . insertAfter (
327
329
j . importDeclaration (
328
330
[ j . importNamespaceSpecifier ( j . identifier ( 'React' ) ) ] ,
329
- j . literal ( 'react' ) ,
331
+ reactLiteral ,
330
332
) ,
331
333
) ;
332
334
}
@@ -345,12 +347,12 @@ module.exports = function(file, api, options) {
345
347
}
346
348
if ( regularImports . length > 0 ) {
347
349
j ( reactPath ) . insertAfter (
348
- j . importDeclaration ( regularImports , j . literal ( 'react' ) ) ,
350
+ j . importDeclaration ( regularImports , reactLiteral ) ,
349
351
) ;
350
352
}
351
353
if ( typeImports . length > 0 ) {
352
354
j ( reactPath ) . insertAfter (
353
- j . importDeclaration ( typeImports , j . literal ( 'react' ) , 'type' ) ,
355
+ j . importDeclaration ( typeImports , reactLiteral , 'type' ) ,
354
356
) ;
355
357
}
356
358
}
0 commit comments