@dloizides/frontend-devtools 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/eslint/index.js
CHANGED
|
@@ -1177,10 +1177,15 @@ function findGuardBinding(ast) {
|
|
|
1177
1177
|
}
|
|
1178
1178
|
function buildGuardImportFix(fixer, sourceCode, utilImportPath) {
|
|
1179
1179
|
const importStatement = `import { ${GUARD_NAME} } from '${utilImportPath}';`;
|
|
1180
|
-
const
|
|
1180
|
+
const body = sourceCode.ast.body;
|
|
1181
|
+
const imports = body.filter((node) => node.type === "ImportDeclaration");
|
|
1181
1182
|
if (imports.length > 0) {
|
|
1182
1183
|
return fixer.insertTextAfter(imports[imports.length - 1], `
|
|
1183
1184
|
${importStatement}`);
|
|
1185
|
+
}
|
|
1186
|
+
if (body.length > 0) {
|
|
1187
|
+
return fixer.insertTextBefore(body[0], `${importStatement}
|
|
1188
|
+
`);
|
|
1184
1189
|
}
|
|
1185
1190
|
return fixer.insertTextBeforeRange([0, 0], `${importStatement}
|
|
1186
1191
|
`);
|