Skip to content

Commit

Permalink
fix(typescript-estree): only call watch callback on new files (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueiniquity authored and JamesHenry committed Mar 19, 2019
1 parent 3b28cac commit 0ef07c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Expand Up @@ -25,7 +25,8 @@
"sourceType": "module",
"ecmaFeatures": {
"jsx": false
}
},
"project": "./tsconfig.base.json"
},
"overrides": [
{
Expand Down
5 changes: 4 additions & 1 deletion packages/typescript-estree/src/tsconfig-parser.ts
Expand Up @@ -28,6 +28,8 @@ const knownWatchProgramMap = new Map<
*/
const watchCallbackTrackingMap = new Map<string, ts.FileWatcherCallback>();

const parsedFilesSeen = new Set<string>();

/**
* Holds information about the file currently being linted
*/
Expand Down Expand Up @@ -71,7 +73,7 @@ export function calculateProjectParserOptions(
// Update file version if necessary
// TODO: only update when necessary, currently marks as changed on every lint
const watchCallback = watchCallbackTrackingMap.get(filePath);
if (typeof watchCallback !== 'undefined') {
if (parsedFilesSeen.has(filePath) && typeof watchCallback !== 'undefined') {
watchCallback(filePath, ts.FileWatcherEventKind.Changed);
}

Expand Down Expand Up @@ -174,6 +176,7 @@ export function calculateProjectParserOptions(
results.push(program);
}

parsedFilesSeen.add(filePath);
return results;
}

Expand Down

0 comments on commit 0ef07c4

Please sign in to comment.