Skip to content

no-duplicate-imports should ignore export * #12760

@mdjermanovic

Description

@mdjermanovic

Tell us about your environment

  • ESLint Version: v6.8.0
  • Node Version: v12.14.0
  • npm Version: v6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
    parserOptions: {
        ecmaVersion: 2015,
        sourceType: "module"
    },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Online Demo Link

/* eslint no-duplicate-imports: ["error", { "includeExports": true }] */

import foo from 'foo';
export * from 'foo';

import { a } from 'bar';
export * from 'bar';

import * as ns from 'baz';
export * from 'baz';

export { a as b } from 'quux';
export * from 'quux';

export { default } from 'quuux';
export * from 'quuux';
eslint index.js

What did you expect to happen?

I think no errors. The rule requires only 1 import/export statement per source module. I'm not sure how to rewrite any of these 5 examples to achieve that. Or any other code with export * and another import/export from the same source, including the test case:

{
    code: "import os from \"os\";\nexport * from \"os\";",
    options: [{ includeExports: true }],
    errors: [{ messageId: "exportAs", data: { module: "os" }, type: "ExportAllDeclaration" }]
}

If I'm not missing something, this rule should probably ignore export *.

What actually happened? Please include the actual, raw output from ESLint.

Errors for all 5 export * declarations:

   4:1  error  'foo' export is duplicated as import  no-duplicate-imports
   7:1  error  'bar' export is duplicated as import  no-duplicate-imports
  10:1  error  'baz' export is duplicated as import  no-duplicate-imports
  13:1  error  'quux' export is duplicated           no-duplicate-imports
  16:1  error  'quuux' export is duplicated          no-duplicate-imports

Are you willing to submit a pull request to fix this bug?

Yes.

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyruleRelates to ESLint's core rules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions