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: message is ignored for star-imports when importNames is defined #11580

Closed
mgol opened this issue Apr 2, 2019 · 4 comments · Fixed by #11791 · May be fixed by Omrisnyk/npm-lockfiles#130
Closed

no-restricted-imports: message is ignored for star-imports when importNames is defined #11580

mgol opened this issue Apr 2, 2019 · 4 comments · Fixed by #11791 · May be fixed by Omrisnyk/npm-lockfiles#130
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

@mgol
Copy link
Contributor

mgol commented Apr 2, 2019

Tell us about your environment

  • ESLint Version: v5.15.3 (but the same happens on v5.16.0 as well)
  • Node Version: v8.15.1
  • npm Yarn Version: 1.15.2

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

@typescript-eslint/parser but it's reproducible with the default one as well

Please show your full configuration:

Configuration
{
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module",
    "rules": {
      "no-restricted-imports": [
        "error",
        {
          "paths": [
            {
              "name": "lodash-es",
              "importNames": ["anything"],
              "message": "Custom message"
            }
          ]
        }
      ],
    }
  }
}

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

import * as _ from 'lodash-es';
eslint path/to/my/file.js

What did you expect to happen?

The provided message should be printed.

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

The custom message is not printed, only the default one:

* import is invalid because 'anything' from 'lodash-es' is restricted

This behavior is even validated by tests. As you can see, the message field is specified but it's not used in the output.

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

Yes

@mgol mgol added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Apr 2, 2019
@platinumazure
Copy link
Member

Hi @mgol, thanks for the bug report.

I can reproduce in this demo. Marking as accepted.

@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Apr 2, 2019
@mgol
Copy link
Contributor Author

mgol commented Apr 2, 2019

@platinumazure I've noticed currently you can't provide messages at all to patterns, only when specifying paths. Would a change allowing patterns to be defined by objects with keys name & message be accepted as well?

@kaicataldo
Copy link
Member

@mgol Let's keep this issue scoped to the bug report. Please feel free to make another issue with a proposal to enhance the rule.

@mgol
Copy link
Contributor Author

mgol commented May 29, 2019 via email

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 30, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 30, 2019
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
3 participants