From 0ef07c4075049018e93592931439757ccc4cf0d0 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Tue, 19 Mar 2019 16:37:02 -0700 Subject: [PATCH] fix(typescript-estree): only call watch callback on new files (#367) --- .eslintrc.json | 3 ++- packages/typescript-estree/src/tsconfig-parser.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e3abc256901..818b90dfab5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -25,7 +25,8 @@ "sourceType": "module", "ecmaFeatures": { "jsx": false - } + }, + "project": "./tsconfig.base.json" }, "overrides": [ { diff --git a/packages/typescript-estree/src/tsconfig-parser.ts b/packages/typescript-estree/src/tsconfig-parser.ts index c136c518c2d..135bbdfbc04 100644 --- a/packages/typescript-estree/src/tsconfig-parser.ts +++ b/packages/typescript-estree/src/tsconfig-parser.ts @@ -28,6 +28,8 @@ const knownWatchProgramMap = new Map< */ const watchCallbackTrackingMap = new Map(); +const parsedFilesSeen = new Set(); + /** * Holds information about the file currently being linted */ @@ -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); } @@ -174,6 +176,7 @@ export function calculateProjectParserOptions( results.push(program); } + parsedFilesSeen.add(filePath); return results; }