Skip to content

Commit 0ef07c4

Browse files
uniqueiniquityJamesHenry
authored andcommitted
fix(typescript-estree): only call watch callback on new files (#367)
1 parent 3b28cac commit 0ef07c4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: .eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"sourceType": "module",
2626
"ecmaFeatures": {
2727
"jsx": false
28-
}
28+
},
29+
"project": "./tsconfig.base.json"
2930
},
3031
"overrides": [
3132
{

Diff for: packages/typescript-estree/src/tsconfig-parser.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const knownWatchProgramMap = new Map<
2828
*/
2929
const watchCallbackTrackingMap = new Map<string, ts.FileWatcherCallback>();
3030

31+
const parsedFilesSeen = new Set<string>();
32+
3133
/**
3234
* Holds information about the file currently being linted
3335
*/
@@ -71,7 +73,7 @@ export function calculateProjectParserOptions(
7173
// Update file version if necessary
7274
// TODO: only update when necessary, currently marks as changed on every lint
7375
const watchCallback = watchCallbackTrackingMap.get(filePath);
74-
if (typeof watchCallback !== 'undefined') {
76+
if (parsedFilesSeen.has(filePath) && typeof watchCallback !== 'undefined') {
7577
watchCallback(filePath, ts.FileWatcherEventKind.Changed);
7678
}
7779

@@ -174,6 +176,7 @@ export function calculateProjectParserOptions(
174176
results.push(program);
175177
}
176178

179+
parsedFilesSeen.add(filePath);
177180
return results;
178181
}
179182

0 commit comments

Comments
 (0)