eslint-plugin-import: `import/no-unresolved` unable to resolve in a monorepo with path mapping
I’m trying to set up path-mapping in a mono-repo. It is working fine, but the import/no-unresolved rule is unable to resolve the paths. My issue seems very similar to #1485, but I already have the eslint-import-resolver-typescript
package installed.
app/
├─ package/
│ ├─ src/
│ ├─ tsconfig.json
.eslintrc
tsconfig.json
.eslintrc looks like
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"import",
],
"extends": [
"eslint:recommended",
"plugin:import/recommended",
"plugin:import/typescript"
],
"settings": {
"import/resolver": {
"typescript": {}
}
}
}
The inner tsconfig.json looks like:
{
"extends": "../tsconfig",
"compilerOptions": {
"baseUrl": "./src/"
}
}
The paths map just fine, but I have the lint error “Unable to resolve path to module ‘…’” wherever I try to use the mapped path. I must be missing a configuration step, or maybe there is an issue with using the baseUrl in a nested tsconfig?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 18 (8 by maintainers)
Thanks! This solves a lot of annoying messages. For anyone who comes after, this is the settings I added; not sure if the project is needed in the node resolver or not.
I think I see that this issue is basically closed, but JounQin touches on something that I’m wondering as I implement this plugin into a new config/project.
Since the Node logic is already handled by typescript, why not make
plugin:import/typescript
do:by default and list
eslint-import-resolver-typescript
as an optional dep.if
eslint-plugin-import
doesn’t do it, maybeeslint-import-resolver-typescript
should ship a lint preset?You also need the
node
resolver, after the typescript one.You need to config
project
settings foreslint-import-resolver-typescript
.The default
project
is onlytsconfig.json
incwd
.