@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.
Files changed (2) hide show
  1. package/dist/index.mjs +16 -7
  2. 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
- const lastImportFixNode = lastImportNode ? checkNewline(lastImportNode, "after") : null;
292
- if (lastImportNode && lastImportFixNode) context.report({
293
- node: lastImportNode,
294
- messageId: "newlineAfterLastImport",
295
- fix: (fixer) => fixer.insertTextAfter(lastImportFixNode, "\n")
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
- if ((!prevNode || !isExportDeclaration(prevNode)) && (!lastImportNode || prevNode !== lastImportNode)) {
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "3.25.0",
3
+ "version": "3.26.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "type": "module",
6
6
  "keywords": [