@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.mjs
CHANGED
|
@@ -1170,10 +1170,15 @@ function findGuardBinding(ast) {
|
|
|
1170
1170
|
}
|
|
1171
1171
|
function buildGuardImportFix(fixer, sourceCode, utilImportPath) {
|
|
1172
1172
|
const importStatement = `import { ${GUARD_NAME} } from '${utilImportPath}';`;
|
|
1173
|
-
const
|
|
1173
|
+
const body = sourceCode.ast.body;
|
|
1174
|
+
const imports = body.filter((node) => node.type === "ImportDeclaration");
|
|
1174
1175
|
if (imports.length > 0) {
|
|
1175
1176
|
return fixer.insertTextAfter(imports[imports.length - 1], `
|
|
1176
1177
|
${importStatement}`);
|
|
1178
|
+
}
|
|
1179
|
+
if (body.length > 0) {
|
|
1180
|
+
return fixer.insertTextBefore(body[0], `${importStatement}
|
|
1181
|
+
`);
|
|
1177
1182
|
}
|
|
1178
1183
|
return fixer.insertTextBeforeRange([0, 0], `${importStatement}
|
|
1179
1184
|
`);
|