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

Fix module resolving when cwd === "babelrc" #45

Closed laurence-hudson-tessella closed 7 years ago

laurence-hudson-tessella commented 7 years ago

Not sure this will fix tleunen/eslint-import-resolver-babel-module#43 in all contexts, but it does for me.

laurence-hudson-tessella commented 7 years ago

If your content with this I'd appreciate an npm release with it in.

tleunen commented 7 years ago

Hi @laurence-hudson-tessella,

As explained in https://github.com/tleunen/eslint-import-resolver-babel-module/issues/43#issuecomment-288358920, we should resolve the string into the proper directory. I wonder how skipping the babelrc value can work, unless your babelrc file is at the root of the project, which will work indeed because the default cwd in the project root.

laurence-hudson-tessella commented 7 years ago

Yes, that is correct. As this PR stands it only covers cases where the babelrc file is at the project root, but that's still an improvement over the current behavior, which never works when cwd === "babelrc".

tleunen commented 7 years ago

This should be resolved with the 4.0.0-beta.0 version, alongside the babel-plugin-module-resolver 3.0.0-beta.0.

Could you confirm please? Will reopen if not.

laurence-hudson-tessella commented 7 years ago

Doesn't look promising:

$ npm outdated
Package                                   Current        Wanted  Latest  
babel-plugin-module-resolver         3.0.0-beta.0  3.0.0-beta.0   2.7.0  
eslint-import-resolver-babel-module  4.0.0-beta.0  4.0.0-beta.0   3.0.0  

with

{
  "plugins": [
    ["module-resolver", {
      "cwd": "babelrc",
      "alias": {
        "~shared": "./src/shared"
      }
    }]
  ]
}

results in a linting failure for every use of the alias.

Let me know if I missed something, or if there is more debugging info I can provide.

tleunen commented 7 years ago

So you're right, there's still an issue with it. Reopening the ticket.

tleunen commented 7 years ago

Will investigate further and see if there's a better fix because I'm not convinced we have to skip the value

codecov[bot] commented 7 years ago

Codecov Report

Merging #45 into master will not change coverage. The diff coverage is 100%.

Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) :arrow_up:
tleunen commented 7 years ago

see #55