Issue
I have the following .eslintrs file in the root of the project:
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": ".",
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "sonarjs", "jest"],
"extends": [
"eslint:recommended",
"airbnb-base",
"airbnb-typescript/base",
"plugin:jest/recommended",
"plugin:sonarjs/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"ignorePatterns": ["!**/*", "/src/kysely/types.ts"],
"rules": {...}
}
And also tsconfig.json in the root:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
// https://nodejs.org/api/packages.html#imports
"@/*": ["./src/*"]
},
"outDir": "dist",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
// "noUncheckedIndexedAccess": true,
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true, // https://github.com/Microsoft/TypeScript/issues/2577
"skipLibCheck": true,
"importHelpers": true,
"target": "es2015",
"lib": ["es2017", "dom"],
"skipDefaultLibCheck": true
},
"include": ["typings/global.d.ts", "src/**/*", "test/**/*", "bin/**/*"],
"exclude": ["node_modules"]
}
However in src/app.module I have the following problem in the first line:
import { Module } from '@nestjs/common';
. Parsing error: Cannot read file 'tsconfig.json'.eslint
I have tried to add in .vscode/settings.json this code:
"eslint.workingDirectories": ["./src"]
but the problem still remains
Solution
Have you try this in your .eslintrc file:
"parserOptions": {
"project": "**/tsconfig.json"
}
I hope this was helpful.
Answered By - Sklehti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.