Skip to content

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

@mgol

Description

@mgol

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

Metadata

Metadata

Assignees

No one assigned

    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