Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Can not use with eslint-plugin-import #85

Closed
HsuTing opened this issue Apr 28, 2018 · 4 comments
Closed

Can not use with eslint-plugin-import #85

HsuTing opened this issue Apr 28, 2018 · 4 comments

Comments

@HsuTing
Copy link

HsuTing commented Apr 28, 2018

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

  • eslint-import-resolver-babel-module: ^4.0.0 | ^5.0.0-beta.0
  • eslint-plugin-import: ^2.11.0
  • babel-core: ^7.0.0-0

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
Copy link
Author

HsuTing commented Apr 28, 2018

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

@HsuTing HsuTing closed this as completed Apr 28, 2018
@HsuTing
Copy link
Author

HsuTing commented Apr 30, 2018

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.

@HsuTing HsuTing reopened this Apr 30, 2018
@jasonleibowitz
Copy link

@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
Copy link
Author

HsuTing commented May 11, 2018

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!

@HsuTing HsuTing closed this as completed May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants