johvin / eslint-import-resolver-alias

a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
MIT License
180 stars 10 forks source link

Is it posible to automatically resolve modules from aliased directory? #13

Closed khataev closed 4 years ago

khataev commented 4 years ago

Suppose I have module alias in package.json:

"_moduleAliases": {
    "@modules": "modules"
  }

why should I have not only alias for modules directory in this plugin's settings, but for each of its children modules (js files)?

"settings": {
    "import/resolver": {
      "alias": {
        "map": [
          ["modules", "./modules"],
          // aliases, I wish to get rid of
          ["@modules/balance-manager", "./modules/balance-manager"],
          ["@modules/coin-finances", "./modules/coin-finances"],
          ["@modules/config", "./modules/config"],
          ["@modules/rub-finances", "./modules/rub-finances"]
        ],
        "extensions": [".ts", ".js", ".jsx", ".json"]
      }
    }
  }
johvin commented 4 years ago

@khataev sorry for the late reply. I think your configuration can be simplified as follows.

"settings": {
    "import/resolver": {
      "alias": {
        "map": [
          ["@modules", "./modules"]
        ],
        "extensions": [".ts", ".js", ".jsx", ".json"]
      }
    }
  }