@@ -57,7 +57,6 @@ module.exports = {
57
57
const openFragMedium = `<${ fragmentPragma } >` ;
58
58
const closeFragMedium = `</${ fragmentPragma } >` ;
59
59
60
- let reactImportFound = false ;
61
60
const reactImports = [ ] ;
62
61
63
62
function reportOnReactVersion ( node ) {
@@ -89,13 +88,11 @@ module.exports = {
89
88
90
89
const fixes = [ ] ;
91
90
92
- // Insert the import statement at the top of the file if `withoutReactPragma` is true
91
+ // Insert the import statement at the top of the file if `withoutReactPragma` is true
93
92
if ( withoutReactPragma ) {
94
93
const ancestors = context . getAncestors ( ) ;
95
94
const rootNode = ancestors . length > 0 ? ancestors [ 0 ] : jsxFragment ;
96
- const reactImport = reactImports . find ( importNode =>
97
- importNode . specifiers . some ( spec => spec . imported && spec . imported . name === fragmentPragma )
98
- ) ;
95
+ const reactImport = reactImports . find ( importNode => importNode . specifiers . some ( ( spec ) => spec . imported && spec . imported . name === fragmentPragma ) ) ;
99
96
100
97
if ( ! reactImport ) {
101
98
// No `Fragment` import found, so add it
@@ -107,12 +104,13 @@ module.exports = {
107
104
fixes . push ( fixer . insertTextAfter ( lastSpecifier , `, ${ fragmentPragma } ` ) ) ;
108
105
} else {
109
106
// Otherwise, add a new import statement at the top
107
+ // eslint-disable-next-line semi
110
108
fixes . push ( fixer . insertTextBefore ( rootNode . body [ 0 ] , `import { Fragment } from 'react';\n\n` ) ) ;
111
109
}
112
110
}
113
111
}
114
112
115
- fixes . push ( fixer . replaceTextRange ( range , source . slice ( range [ 0 ] , range [ 1 ] + lengthDiff ) ) )
113
+ fixes . push ( fixer . replaceTextRange ( range , source . slice ( range [ 0 ] , range [ 1 ] + lengthDiff ) ) ) ;
116
114
117
115
return fixes ;
118
116
} ;
@@ -217,11 +215,9 @@ module.exports = {
217
215
ImportDeclaration ( node ) {
218
216
if ( node . source && node . source . value === 'react' ) {
219
217
reactImports . push ( node ) ;
220
- let hasFragment = false ;
221
218
222
219
node . specifiers . forEach ( ( spec ) => {
223
220
if ( spec . imported && spec . imported . name === fragmentPragma ) {
224
- hasFragment = true ;
225
221
if ( spec . local ) {
226
222
fragmentNames . add ( spec . local . name ) ;
227
223
}
0 commit comments