tleunen / eslint-import-resolver-babel-module

Custom eslint resolve for babel-plugin-module-resolver
https://github.com/tleunen/babel-plugin-module-resolver
MIT License
248 stars 31 forks source link

Can not use with eslint-plugin-import #85

Closed HsuTing closed 6 years ago

HsuTing commented 6 years ago

I try to use eslint-plugin-import with eslint-import-resolver-babel-module. This can not work.

When I use eslint, and .eslintcache does not exit. It show:

[eslint-import-resolver-babel-module] TypeError: Cannot read property 'find' of undefined

I found the problem is here.

HsuTing commented 6 years ago

Oh, my fault. I found the problem. I had a filename eslint.js. Sorry to disturb you.

HsuTing commented 6 years ago

I still get [eslint-import-resolver-babel-module] TypeError: Cannot read property 'find' of undefined, when import/no-unresolved is detected.

[eslint-import-resolver-babel-module] TypeError: Cannot read property 'find' of undefined
    at result.plugins.filter.plugin (**/node_modules/eslint-import-resolver-babel-module/lib/index.js:20:50)

eslint does work, but I think this error should not be shown.

jasonleibowitz commented 6 years ago

@HsuTing Found a workaround from #67. The latest version of this library is 5.0.0-beta.0. If you update this library to that version this issue is resolved.

I'm not sure why the default version in npm is 4.0.0. Probably because v5 is marked as beta.

HsuTing commented 6 years ago

Oh! Sorry, I found the solution. If using eslint-import-resolver-babel-module with eslint-plugin-import, we should set like this:

module.exports = {
  ...
  settings: {
    'import/resolver': {
      node: {},  // need to add this
      'babel-module': alias,
    },
  },
  ...
};

@jasonleibowitz Thank for your answer!