diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 22fdc8a110f7..ec594b109c24 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -425,7 +425,7 @@ class ManualMemoizationChecker { } } - const manualMemoErrors = this.findViolations([...enforcedAutoMemoFiles]); + const manualMemoErrors = this.findViolations(enforcedAutoMemoFiles); return { manualMemoErrors, @@ -450,14 +450,15 @@ class ManualMemoizationChecker { filesWithErrors.add(filePath); - if (file.diffType === 'added') { + const isAddedFile = file.diffType === 'added'; + if (isAddedFile) { addedFiles.add(filePath); } const isReactComponentSourceFile = this.FILE_EXTENSIONS.some((extension) => filePath.endsWith(extension)); - const isSuccessfullyCompiled = successFiles.has(filePath); - if (isReactComponentSourceFile && isSuccessfullyCompiled) { + + if (isReactComponentSourceFile && isSuccessfullyCompiled && isAddedFile) { enforcedAutoMemoFiles.add(filePath); } } @@ -465,7 +466,7 @@ class ManualMemoizationChecker { return {addedFiles, enforcedAutoMemoFiles}; } - private static findViolations(files: string[]): Map { + private static findViolations(files: Set): Map { const manualMemoErrors = new Map(); for (const file of files) {