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

Support leading slashes in paths #86

Closed
qmg-akara opened this issue Dec 2, 2021 · 9 comments
Closed

Support leading slashes in paths #86

qmg-akara opened this issue Dec 2, 2021 · 9 comments

Comments

@qmg-akara
Copy link

Hello, thanks for this great work!

We have some special aliases that starts with a leading slash, such as /opt/nodejs/lambda-layer and tsc successfully compiles this code however we are getting import/no-unresolved error for these aliases. When we remove the leading slash, i.e. opt/nodejs/lambda-layer, it works fine.

tsconfig.eslint.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "/opt/nodejs/lambda-layer": ["./packages/lambdaLayer/src"]
    }
  },
  "include": ["**/*.ts"],
  "exclude": ["**/node_modules"]
}

error:
Unable to resolve path to module '/opt/nodejs/lambda-layer' import/no-unresolved

tsc --build builds the code successfully so I wonder if this is a bug in eslint-import-resolver-typescript or am I missing something? Thanks

@JounQin
Copy link
Collaborator

JounQin commented Dec 2, 2021

tsconfig-paths is used under the hood.

See also dividab/tsconfig-paths#128

@qmg-akara
Copy link
Author

Thanks @JounQin for the prompt reply! and the link. As this is a tsconfig-paths issue I'm going to close this. Thanks

@qmg-akara
Copy link
Author

Or I'm opening for tracking the tsconfig-paths issue, so once it is resolved, eslint-import-resolver-typescript could upgrade tsconfig-paths. Feel free to close if you think no need to keep this open.

@qmg-akara qmg-akara reopened this Dec 2, 2021
@JounQin
Copy link
Collaborator

JounQin commented Dec 2, 2021

@qmg-akara You can try to use patch-package and patch tsconfig-paths by editing lib/try-path.js like https://github.com/dividab/tsconfig-paths/pull/180/files temporarily.

@qmg-akara
Copy link
Author

Thanks @JounQin for letting me know that! I think we'll just disable import/no-unresolved for now until it is resolved. Thanks

@qmg-akara
Copy link
Author

Hi @JounQin , looks like tsconfig-paths issue is resolved, would it be possible to update this package too? Thanks

@JounQin
Copy link
Collaborator

JounQin commented Mar 14, 2022

We use "tsconfig-paths": "^3.9.0", so it's free to upgrade tsconfig-paths to 3.14+ by yourself.

@qmg-akara
Copy link
Author

Looks like there is no an official way of upgrading indirect dependencies, I have created a PR here

@JounQin
Copy link
Collaborator

JounQin commented Mar 14, 2022

You can delete it from yarn.lock or something else, or just reinstall this resolver.

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

Successfully merging a pull request may close this issue.

2 participants