Skip to content

Commit 43cd785

Browse files
committed
fix(core): clear cache if any fix exists on retry
1 parent c83eeda commit 43cd785

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/core/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function createLinter(
4545
title: string;
4646
getEdits: () => ts.FileTextChanges[];
4747
}[]>,
48-
{
48+
refactors: {
4949
title: string;
5050
diagnostic: ts.DiagnosticWithLocation;
5151
getEdits: () => ts.FileTextChanges[];
@@ -130,7 +130,7 @@ export function createLinter(
130130
file: rulesContext.file,
131131
relatedInformation: cacheDiagnostic.relatedInformation?.map(info => ({
132132
...info,
133-
file: info.file ? (syntaxOnlyLanguageService as any).getNonBoundSourceFile(info.file.fileName) : undefined,
133+
file: info.file ? getNonBoundSourceFile?.(info.file.fileName) : undefined,
134134
})),
135135
}, []);
136136
}
@@ -172,6 +172,10 @@ export function createLinter(
172172
if (shouldRetry) {
173173
// Retry
174174
shouldEnableTypeAware = true;
175+
if (cache && Object.values(cache[1]).some(([hasFix]) => hasFix)) {
176+
cache[1] = {};
177+
cache[2] = {};
178+
}
175179
return this.lint(fileName, cache);
176180
}
177181

@@ -189,6 +193,10 @@ export function createLinter(
189193
if (!typeAwareMode) {
190194
// Retry
191195
shouldEnableTypeAware = true;
196+
if (cache && Object.values(cache[1]).some(([hasFix]) => hasFix)) {
197+
cache[1] = {};
198+
cache[2] = {};
199+
}
192200
return this.lint(fileName, cache);
193201
}
194202
throw error;

0 commit comments

Comments
 (0)