Why this happens?
I’m not entirely sure, but it seems like @typescript-eslint/parser tries to compare files covered in the eslint configuration (for example by extension) with files included in tsconfig.json. Since the .js files are covered by @typescript-eslint/parser and depending on your eslint configuration, the file is probably included in the eslint run. But because the file isn’t included in tsconfig, you get this error.
How to fix that?
Depending on your case, you can select one of them:
- You can ignore it in
.eslintignore. This is what @U4EA did. - If can add it to the includes in
tsconfig.json:
"include": [
".eslintrc.js",
// another includes
]
- If you don’t have a “right” tsconfig.json, because you use a monorepo, then you can create a new file
tsconfig.eslint.json:
{
"include": [
".eslintrc.js"
]
}
and use this file inside .eslintrc.js for eslint only:
parserOptions: {
project: [
'./tsconfig.eslint.json',
'./packages/*/tsconfig.json',
],
},