eslint-import-resolver-babel-module icon indicating copy to clipboard operation
eslint-import-resolver-babel-module copied to clipboard

[Feature request] get aliases from .babelrc config

Open AoDev opened this issue 5 years ago • 5 comments

First of all, I am unaware of all the "magic" around babel and the plugins. If what I say next is not relevant just let me know and we can close this.

I managed to make everything work by basically copying my aliases in .babelrc to .eslintrc. This seems very redundant. Couldn't we have eslint-import-resolver-babel-module look for the aliases from babel config?

.babelrc

{
  "plugins": [
    [
      "module-resolver",
      {
        "alias": {
          "ui-framework": "./src/ui-framework",
          "app-utils": "./src/application/utils",
          "app-services": "./src/application/services"
        }
      }
    ],

.eslintrc

  "settings": {
    "import/resolver": {
      "babel-module": {
        "alias": {
          "ui-framework": "./src/ui-framework",
          "app-utils": "./src/application/utils",
          "app-services": "./src/application/services"
        }
      }
    }
  }

AoDev avatar Sep 14 '18 12:09 AoDev

This looks definitely like a bug. It should definitely reuse the config from Babel.

tleunen avatar Sep 18 '18 14:09 tleunen

Ok, I didn't know if it was supposed to take the config from there or not. I will verify again, just so you don't lose your time.

AoDev avatar Sep 18 '18 15:09 AoDev

So, I removed the whole settings part of my .eslintrc

This:

  "settings": {
    "import/resolver": {
      "babel-module": {
        "alias": {
          ...

And confirm I get this lint error:

/Volumes/DataUser/git-repos/cryptovista/electron-app/src/application/stores/RouterStore.js
  2:26  error  Unable to resolve path to module 'app-utils'  import/no-unresolved

/Volumes/DataUser/git-repos/cryptovista/electron-app/src/application/stores/UIStore.js
  4:24  error  Unable to resolve path to module 'shared-components/viewModels'  import/no-unresolved

My eslint dependencies:

    "eslint": "5.2.0",
    "eslint-config-standard": "11.0.0",
    "eslint-import-resolver-babel-module": "5.0.0-beta.1",
    "eslint-loader": "2.1.0",
    "eslint-plugin-import": "2.13.0",
    "eslint-plugin-lodash": "2.7.0",
    "eslint-plugin-node": "7.0.1",
    "eslint-plugin-promise": "3.8.0",
    "eslint-plugin-react": "7.10.0",
    "eslint-plugin-standard": "3.1.0",

AoDev avatar Sep 18 '18 15:09 AoDev

This problem seems to be solved in the latest beta.

kjagiello avatar Sep 28 '18 11:09 kjagiello

I've had this error in v.4.0.0 Upgrading to 5.0.0-beta.1 as @kjagiello pointed solved the issue!

wallynm avatar Oct 05 '18 16:10 wallynm