Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-restricted-imports doesn't restrict export * when importNames are configured #12737

Closed
mdjermanovic opened this issue Jan 3, 2020 · 3 comments · Fixed by #12798
Closed
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@mdjermanovic
Copy link
Member

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-restricted-imports: ["error",
  {
    name: "mod1"  
  },
  {
    name: "mod2",
    importNames: ["a"]
  }
]*/

import * as foo from "mod1"; // error
export * from "mod1"; // error

import { a } from "mod2"; // error
export { a } from "mod2"; // error
import * as bar from "mod2"; // error
export * from "mod2"; // no error, is this a bug?
eslint index.js

What did you expect to happen?

Errors for the first 5 declarations.

I'm not sure what should be expected behavior for export * from "mod2". That is the question of this issue.

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

Errors for the first 5 declarations, as expected.

No error for export * from "mod2".

  11:1  error  'mod1' import is restricted from being used                no-restricted-imports
  12:1  error  'mod1' import is restricted from being used                no-restricted-imports
  14:1  error  'mod2' import is restricted from being used                no-restricted-imports
  15:1  error  'mod2' import is restricted from being used                no-restricted-imports
  16:1  error  * import is invalid because 'a' from 'mod2' is restricted  no-restricted-imports

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

Yes.

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 3, 2020
@kaicataldo
Copy link
Member

It makes sense to me to treat import * as bar from "mod2"; and export * from "mod2"; similarly and error on the latter as well.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 4, 2020
@mdjermanovic
Copy link
Member Author

As for the PR, seems best to finish and merge #12711 first and then do the PR for this fix on top of the changes from #12711.

@mdjermanovic
Copy link
Member Author

I'm working on this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants