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

Comments

Projects
None yet
3 participants
@mgol
Copy link
Contributor

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 triage labels Apr 2, 2019

@platinumazure

This comment has been minimized.

Copy link
Member

commented Apr 2, 2019

Hi @mgol, thanks for the bug report.

I can reproduce in this demo. Marking as accepted.

@platinumazure platinumazure added accepted rule and removed triage labels Apr 2, 2019

@mgol

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

commented May 29, 2019

@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

This comment has been minimized.

Copy link
Contributor Author

commented May 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.