I'm trying to use eslint-import-resolver-typescript
in a monorepo project but I have an unresolved ESlint error despite the right config (I believe).
This is the architecture of the project:
api/
src/
index.ts
package.json
tsconfig.json
app/
package.json
tsconfig.json
.eslintrc
tsconfig.json
package.json
And this is the configuration of each config files:
tsconfig.json
{
"compilerOptions": {
"allowJs": false,
"alwaysStrict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["dom", "es2020"],
"module": "es2020",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2020",
"typeRoots": ["typings", "node_modules/@types"]
},
"references": [
{
"path": "./api"
},
{
"path": "./app"
}
]
}
api/tsconfig.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "./src",
"composite": true,
"module": "commonjs",
"outDir": "dist",
},
"include": ["./src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}
app/tsconfig.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"composite": false
},
"exclude": ["node_modules"],
"include": ["./**/*.ts", "./**/*.tsx"]
}
.eslintrc
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": ["./api/tsconfig.json", "./app/tsconfig.json"]
},
"plugins": ["@typescript-eslint", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended"
],
"env": {
"browser": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"directory": ["./api/tsconfig.json", "./app/tsconfig.json"]
}
}
}
}
In my api/src/index.ts
file when I import express with default import syntax import express from "express"
I have this error :
No default export found in imported module "express". eslint(import/default)
I have @types/express
installed in devDependencies. Could you check if I missed something in my ESlint config or if it's a bug with composite tsconfig that doesn't understand allowSyntheticDefaultImports
option ?