import-js/eslint-plugin-import

`named` rule not working

Open

#901 aberto em 21 de jul. de 2017

Ver no GitHub
 (10 comments) (2 reactions) (0 assignees)JavaScript (1.540 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (4.946 stars)
Métricas de merge de PR
 (Mesclagem média 138d 22h) (3 fundiu PRs em 30d)

Description

Hi,

First off, thanks for the great plugin. The named rule doesn't seem to be working for me (at least as expected) while others do.

Context

package.json

 $ egrep 'eslint-.*import' package.json

    "eslint-import-resolver-webpack": "^0.8.3",
    "eslint-plugin-import": "^2.7.0",

.eslintrc

{
    "parser": "babel-eslint",
    ...
    "settings": {
        ...
        "import/resolver": {
            "webpack": {
                "config": "webpack.prod.config.js"
            }
        }
    },
    ...
    "extends": [
         ...
        "plugin:import/errors",
        "plugin:import/warnings"
    ],
    "rules": {
        "max-len": ["error", 80, 2, { "ignoreUrls": true }],

        // Don't warn us about using console.log (though that should only
        // happen in the dev environment).
        "no-console": [0]
    },
    ...
}

Issue

I've got a file with the following contents

import { logToSentry, butts } from './errors'

const errorAlert = (msg, err) => {
  logToSentry(msg, err);
  butts();
}

As you can probably imagine, butts doesn't exist in ./errors and certainly isn't exported. Eslint raises no issue about this.

However, I know that eslint-plugin-import is doing something because if I change ./errors to a path that doesn't exist, I get the following output from eslint:

/code/actions.jsx
  5:36  error  Unable to resolve path to module './errorsDoesntExist'  import/no-unresolved

✖ 1 problem (1 error, 0 warnings)

So why would one rule be working (import/no-unresolved) but not the other (import/named)? Any guidance is much appreciated.

Guia do colaborador