import-js / import-js/eslint-plugin-import
`named` rule not working
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 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
```js
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 `export`ed. 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.
Contributor guide
Research direction
Reproduce the report using the package.json dependencies, .eslintrc settings, and webpack.prod.config.js resolver configuration. Compare the behavior of import/no-unresolved and import/named for the shown ./errors import, then verify that named reports the non-exported butts binding without breaking valid imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript, webpack
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100