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

Question #3

Closed thales-gaddini closed 6 years ago

thales-gaddini commented 6 years ago

Hi, thanks for the plugin!

I wanted to know if the plugin accepts something like this?

module.exports = {
  "settings": {
    "import/resolver": {
      "alias": [
        ["apis/*", "./app/apis/*"],
        ["constants/*", "./app/constants/*"],
        ["state/*", "./app/state/*"],
        ["utilities/*", "./app/utilities/*"],
      ]
    }
  }
}

If yes, do you know why I'm having trouble with that configuration? If no, think this could be an enhancement?

Thanks again!

johvin commented 6 years ago

@thales-gaddini The answer is yes. You can achieve the goal with the following configuration.

module.exports = {
  "settings": {
    "import/resolver": {
      "alias": [
        ["apis", "./app/apis"],
        ["constants", "./app/constants"],
        ["state", "./app/state"],
        ["utilities", "./app/utilities"],
      ]
    }
  }
}
johvin commented 6 years ago

@thales-gaddini I feel so sorry that I have just realized I misled you about this issue. The configuration is right, but there's a bug(#5) with the plugin which led to your trouble. The bug has been fixed now and you will get what you want by upgrading its version to 1.1.1. Sorry for that again.

julien-amblard commented 5 years ago

Hello, did this bugfix still is in 1.1.2 version ? i have the same issue, i can't create alias for subfolders

in my case, this work :

module.exports = {
    settings: {
        'import/resolver': {
            alias: {
                map: [
                    ['^Client', './client']
                ],
                extensions: ['.js', '.jsx', '.json']
            }
        }
    }
};

this don't :

module.exports = {
    settings: {
        'import/resolver': {
            alias: {
                map: [
                    ['^Components', './client/components']
                ],
                extensions: ['.js', '.jsx', '.json']
            }
        }
    }
};

Thank you !

johvin commented 5 years ago

@seloger-AmblardJulien Can you provide the simplified source code and file structure of your project to help me to reproduce the problem better.