-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
n/a
Repro Code
The problem is a Windows filesystem issue, so can't repro in playground.
The code actually doesn't matter, as the issue is related to filenames in Windows.
ESLint Config
{
"root": true,
"overrides": [
{
"parserOptions": {
"project": ["./tsconfig.json"]
},
"files": ["*.ts"],
"extends": [
"plugin:@typescript-eslint/recommended-requiring-type-checking"
]
}
]
}
tsconfig
Expected Result
See attached .zip file.
- Have filenames
Foo.ts
andBar.ts
- Both files should produce lint error:
Unsafe return of an
anytyped value @typescript-eslint/no-unsafe-return
Actual Result
Only Bar.ts
is linted, and Foo.ts
incorrectly shows an error related to the file not being included in tsconfig.json
.
> npx eslint .
C:\Projects\symless\ts-sandbox\src\Bar.ts
2:3 error Unsafe return of an `any` typed value @typescript-eslint/no-unsafe-return
C:\Projects\symless\ts-sandbox\src\Foo.ts
0:0 error Parsing error: ESLint was configured to run on `<tsconfigRootDir>/src\Foo.ts` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
✖ 2 problems (2 errors, 0 warnings)
Additional Info
Searched issues for "upper case chars windows" and found no matches.
Workaround: Rename all files to lower case (bug does not occur with lower case).
I also rasied a bug with eslint (eslint/eslint#18003), but they redirected me here.
Some pertinent details:
This bug doesn't seem to be relevant to ESLint config or source file. It's a transient hard to reproduce issue related to the Windows filesystem. I have access to multiple Windows computers, and it only happens on one of them.
I narrowed the problem down to
node_modules\@typescript-eslint\typescript-estree\dist\create-program\getWatchProgramsForProjects.js
:
if (fileList.has(filePath)) {
log('Found existing program for file. %s', filePath);
updatedProgram ??= existingWatch.getProgram().getProgram();
// sets parent pointers in source files
updatedProgram.getTypeChecker();
return [updatedProgram];
}
For some reason,
updatedProgram
doesn't contain the source file that is being linted:
updatedProgram.getSourceFiles().map(file=>file.fileName).join(", ")
The filename is missing from this list.