Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript-estree): only call watch callback on new files #367

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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