-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[import/no-unresolved] when using with typescript "baseUrl" and "paths" option #1485
Comments
You'd have to use a typescript resolver for that, and configure it in your eslint settings. See https://github.com/benmosher/eslint-plugin-import#resolvers and https://github.com/benmosher/eslint-plugin-import/wiki/Resolvers |
Thanks! For other folks, this solves the issue. npm install eslint-import-resolver-typescript package.json {
// other configuration are omitted for brevity
settings: {
"import/resolver": {
typescript: {} // this loads <rootdir>/tsconfig.json to eslint
},
},
} |
@jjangga0214
should be added to |
I needed to reopen my vscode but this worked very well, thanks |
@jjangga0214 thanks for the suggestion. btw, I also added cheers |
I've already been using typescript resolver but it was necessary to add |
Yes! For monorepo projects, this is the required configuration. I was confused until I read your comment, thanks! |
Supress errors related to `import/no-unresolved` with typescript files (import-js/eslint-plugin-import#1485)
Supress errors related to `import/no-unresolved` with typescript files (import-js/eslint-plugin-import#1485)
And for settings:
import/resolver:
typescript: {} |
Is there a configuration, whether with |
@jneander no, not that i know of. I'd suggest omitting the extension, and using babel instead of tsc as your transpiler (regardless), and then it'd be trivial to add a babel plugin that adds the extensions whenever needed. |
Updated README.md
Updated README.md
Well, it does not work anymore, hours trying to make it work and I couldn't. |
Dose not work
|
Hi, it does not work for me using nextjs + typescript + eslint My eslint file
In tsconfig.json i use
and get errors from eslint like
Compilation build all works great, just linting fails eslint |
Sounds like a new issue would be appropriate; commenting on a closed one isn’t likely to help anything. |
Next.js supports tsconfig path alias out of the box. Reference: https://nextjs.org/docs/advanced-features/module-path-aliases Then, resolve eslint error. Thanks: import-js/eslint-plugin-import#1485
Next.js supports tsconfig path alias out of the box. Reference: https://nextjs.org/docs/advanced-features/module-path-aliases Then, resolve eslint error. Thanks: import-js/eslint-plugin-import#1485 Removed import/recommended, because it was causing unnecessary error.
By the way, by now it seems if you've got a TS app in VSCode with your Therefore your best option is just:
It took me a while to figure that out, and I kicked myself when I did. |
thank you bro, I did wonder why I'm spending 5+ hours trying to fix this rubbish when if the pathing was broken TS would of told me, I should of not been so stubborn, set and forget, how miserable HAHA |
@jjangga0214 if this issue is still happening, it should not be solved. |
@SalahAdDin What do you mean? Sorry, I don't understand your message. |
One hour ago, a new answer, so, the issue still happends. |
Repro
tree
tsconfig.json
Other options are omiited for brevity.
.eslintrc.js
Other options are omiited for brevity.
src/index.ts
Problem
Expected Result
It should respect
baseUrl
andpaths
option on tsconfig.jsonActual Result
Additional Info
https://github.com/jjangga0214/ts-boilerplate/commit/af74c178a3c5ee84f78c520ba3c09ad73a9fc130/checks is the actual result with an error message. (Expand it by clicking "Lint" on github action checks)
Versions
@typescript-eslint/eslint-plugin
2.2.0
@typescript-eslint/parser
2.2.0
eslint-plugin-import
2.18.2
TypeScript
3.6.3
ESLint
5.3.0
node
12.6.0
npm
6.10.2
yarn
1.17.3
The text was updated successfully, but these errors were encountered: