Skip to content

Commit d197012

Browse files
committed
fix linter
1 parent 74efbf7 commit d197012

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/rules/jsx-fragments.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ module.exports = {
5757
const openFragMedium = `<${fragmentPragma}>`;
5858
const closeFragMedium = `</${fragmentPragma}>`;
5959

60-
let reactImportFound = false;
6160
const reactImports = [];
6261

6362
function reportOnReactVersion(node) {
@@ -89,13 +88,11 @@ module.exports = {
8988

9089
const fixes = [];
9190

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
9392
if (withoutReactPragma) {
9493
const ancestors = context.getAncestors();
9594
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));
9996

10097
if (!reactImport) {
10198
// No `Fragment` import found, so add it
@@ -107,12 +104,13 @@ module.exports = {
107104
fixes.push(fixer.insertTextAfter(lastSpecifier, `, ${fragmentPragma}`));
108105
} else {
109106
// Otherwise, add a new import statement at the top
107+
// eslint-disable-next-line semi
110108
fixes.push(fixer.insertTextBefore(rootNode.body[0], `import { Fragment } from 'react';\n\n`));
111109
}
112110
}
113111
}
114112

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)));
116114

117115
return fixes;
118116
};
@@ -217,11 +215,9 @@ module.exports = {
217215
ImportDeclaration(node) {
218216
if (node.source && node.source.value === 'react') {
219217
reactImports.push(node);
220-
let hasFragment = false;
221218

222219
node.specifiers.forEach((spec) => {
223220
if (spec.imported && spec.imported.name === fragmentPragma) {
224-
hasFragment = true;
225221
if (spec.local) {
226222
fragmentNames.add(spec.local.name);
227223
}

0 commit comments

Comments
 (0)