Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to put an alias using regexp #2

Open
wizevlad opened this issue Jul 8, 2021 · 2 comments
Open

How to put an alias using regexp #2

wizevlad opened this issue Jul 8, 2021 · 2 comments

Comments

@wizevlad
Copy link

wizevlad commented Jul 8, 2021

The problem, I have this folder structure:

+ src
    - components
    - pages
    - state
    - utils

My jsconfig.json sets src as baseUrl:

{
  "compilerOptions": {
    "baseUrl": "src"
  }
}

So I import files using this notation:

import getFilename from 'utils/files/getFilename'

Using this plugin, I need to create an alias for all 4 subfolders and I want to say: "Every direct child inside src should be aliased".

Is that doable? Something like:

"settings": {
    "import/resolver": {
      "eslint-import-resolver-custom-alias": {
        "alias": {
          "*": "./src/*"
        },
        "extensions": [".js", ".jsx"]
      }
    }
  },
@jonathanwinglee
Copy link

jonathanwinglee commented Oct 21, 2021

@wizevlad were you able to figure this out? I'd like to do something similar, no luck thus far.

@laysent
Copy link
Owner

laysent commented Oct 24, 2021

I have created a PR #5 , please see if this will solve the problem.
Here is what I think: perhaps * is too complicated for the solution, as I don't think one would create some configuration like "root/*": "./src/*". Thus instead, I create a special case for empty string, i.e. "": "./src" instead.

Let me know if you have any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants