@so1ve/eslint-plugin 3.24.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 +17 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -270,7 +270,7 @@ const rule$7 = createEslintRule({
|
|
|
270
270
|
expectedLine = endNode.loc.end.line + 1;
|
|
271
271
|
tokenLine = token?.loc.start.line;
|
|
272
272
|
const commentLine = nextComment?.loc.start.line;
|
|
273
|
-
if (token && (expectedLine === tokenLine || expectedLine === commentLine) && token.value !== "}" && token.value !== "<\/script>") return endNode;
|
|
273
|
+
if (token && (expectedLine === tokenLine || expectedLine === commentLine || tokenLine === endNode.loc.end.line) && token.value !== "}" && token.value !== "<\/script>") return endNode;
|
|
274
274
|
return null;
|
|
275
275
|
}
|
|
276
276
|
const startNode = sourceCode.getCommentsBefore(node)[0] || node;
|
|
@@ -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,
|