@so1ve/eslint-plugin 3.25.0 → 3.26.0
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/index.mjs +16 -7
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -288,15 +288,24 @@ const rule$7 = createEslintRule({
|
|
|
288
288
|
ExportDefaultDeclaration: checkExport,
|
|
289
289
|
ExportAllDeclaration: checkExport,
|
|
290
290
|
"Program:exit"() {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
if (lastImportNode) {
|
|
292
|
+
const parent = lastImportNode.parent;
|
|
293
|
+
const nextNode = getNextNode(lastImportNode);
|
|
294
|
+
const isLastInBlock = parent && "body" in parent && Array.isArray(parent.body) && parent.body[parent.body.length - 1] === lastImportNode;
|
|
295
|
+
if (nextNode && !isLastInBlock) {
|
|
296
|
+
const lastImportFixNode = checkNewline(lastImportNode, "after");
|
|
297
|
+
if (lastImportFixNode) context.report({
|
|
298
|
+
node: lastImportNode,
|
|
299
|
+
messageId: "newlineAfterLastImport",
|
|
300
|
+
fix: (fixer) => fixer.insertTextAfter(lastImportFixNode, "\n")
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
297
304
|
for (const node of exportNodes) {
|
|
298
305
|
const prevNode = getPreviousNode(node);
|
|
299
|
-
|
|
306
|
+
const parent = node.parent;
|
|
307
|
+
const isFirstInBlock = parent && "body" in parent && Array.isArray(parent.body) && parent.body[0] === node;
|
|
308
|
+
if ((!prevNode || !isExportDeclaration(prevNode)) && (!lastImportNode || prevNode !== lastImportNode) && !isFirstInBlock) {
|
|
300
309
|
const beforeFixNode = checkNewline(node, "before");
|
|
301
310
|
if (beforeFixNode) context.report({
|
|
302
311
|
node,
|