eslint-plugin-import: [import/no-unresolved] not working for index.js

similar but different: https://github.com/benmosher/eslint-plugin-import/issues/1124

screenshot 2019-02-19 at 20 45 03

file struct:

utils/
    index.js
components/
    Foo.jsx
.eslintrc.js
webpack.config.js

utils/index.js:

export function getPromise () { return 42; }

components/Foo.jsx:

import { getPromise } from 'utils';

.eslintrc:

{
  "parser": "babel-eslint",
  "plugins": [
    "import",
  ],
  "settings": {
    "import/resolver": {
      "webpack": {
        "config": path.resolve(__dirname, "webpack.config.js"),
      }
    },
  },
  "rules": {
    "import/no-unresolved": ["error", {commonjs: true, caseSensitive: true}],
    // ...
  }
}

webpack.config.js:

{
  context: root,
  resolve: {
    modules: [root, 'node_modules'],
    extensions: ['.js', '.jsx', '.json', '.coffee', '.cjsx'],
  },
  // ...
}

versions: all are latest

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 13
  • Comments: 16 (4 by maintainers)

Most upvoted comments

No one wanna write awful '../../../../MyComponent' imports, right? 😃

Excuse my inaccuracy

I’m not about /Users/mxtnr/projects/project/blah/blah/Foo.jsx I’m about blah/blah/Foo.jsx rather than ../../../blah/Foo.jsx

usually I’d like to write code like import utils from '@/utils' rather than import utils from '@/utils/index.js'.

That’s interesting solution… We’ll think about it.

I have default macOS config. MacOS suggests case-insensitive FS setting by default. Anyway, I can check case in my github repo. so utils/index.js is not capitalized 🤔

I do - I think they’re a correct and proper indication that I have code that needs extracting into a separate package 😃

In this case, tho, the error message is warning you about capitalization. If you import from utils/index.js, what happens?