eslint-plugin-import: import/export - Multiple exports triggered when duplication isn't relevant

I get the error Multiple exports of name 'List' from both lines of components/pages/index.js in following example:

// components/pages/index.js
export * as Messages from "./messages";
export * as Users from "./users";

// components/pages/messages/index.js
export List from "./list";
export Show from "./show";

// components/pages/users/index.js
export Edit from "./edit";
export List from "./list";

// components/pages/messages/list.js => React Component
// components/pages/messages/show.js => React Component
// components/pages/users/edit.js => React Component
// components/pages/users/list.js => React Component

I understand that if I get it once, I’ll get it twice, but I don’t think it should be happening at all. The code itself works when I access my components (Pages.Users.List) leading me to believe this is a bug in the rule. I also made sure to update to the latest version (2.20.1) before submitting this

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 18 (11 by maintainers)

Most upvoted comments

I started to attempt a fix today and ran into an issue with the current ecmaVersion being too old for the syntax. But after I updated that, I found out the issue has already been fixed! Potentially here. Below is a test specifically for it that I can add, but I don’t know if there are any further repercussions for updating the ecmaVersion

--- a/tests/src/rules/export.js
+++ b/tests/src/rules/export.js
@@ -35,6 +35,12 @@ ruleTester.run('export', rule, {
         export { A, B };
       `,
     }),
+    test({
+      code: `
+        export * as A from './named-export-collision/a';
+        export * as B from './named-export-collision/b';
+      `,
+    }),
   ],

   invalid: [
diff --git a/tests/src/utils.js b/tests/src/utils.js
index 0f45e7b..0892482 100644
--- a/tests/src/utils.js
+++ b/tests/src/utils.js
@@ -37,7 +37,7 @@ export function test(t) {
   }, t, {
     parserOptions: Object.assign({
       sourceType: 'module',
-      ecmaVersion: 9,
+      ecmaVersion: 11,
     }, t.parserOptions),
   })
 }

Long story short, this is fixed on version 2.22.0. Thanks @ljharb!

Also ran into this issue with the following code:

export * as WorkerPhoneCreated from './phone/created';
export * as WorkerPhoneUpdated from './phone/updated';

Both the following imported files contain an EventType export, and should be referenced as WorkerPhoneCreated.EventType and WorkerPhoneUpdated.EventType respectively and so I think this “multiple exports” error is a false positive if I’ve understood correctly.