From 5925d2d3e730a6827fcda643e6acd0369c15a7ee Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 8 Oct 2025 17:34:48 +0100 Subject: [PATCH 01/78] feat: add logic to suppress certain healthcheck errors --- scripts/react-compiler-compliance-check.ts | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 775c68958360..cb9b9765ba7f 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -16,6 +16,12 @@ import {bold, info, log, error as logError, success as logSuccess, note, warn} f const DEFAULT_REPORT_FILENAME = 'react-compiler-report.json'; +const SUPPRESSED_COMPILER_ERRORS = [ + // This error is caused by an internal limitation of React Compiler + // https://github.com/facebook/react/issues/29583 + '(BuildHIR::lowerExpression) Expected Identifier, got MemberExpression key in ObjectExpression', +] as const satisfies string[]; + type HealthcheckJsonResults = { success: string[]; failures: CompilerFailure; @@ -172,6 +178,12 @@ function parseCombinedOutput(output: string): CompilerResults { reason: failureWithReasonMatch[4], }; + // Skip if this error should be suppressed + if (shouldSuppressError(newFailure)) { + currentFailure = null; + continue; + } + const key = getUniqueFileKey(newFailure); // Only add if not already exists, or if existing one has no reason const existing = failure.get(key); @@ -226,6 +238,13 @@ function parseCombinedOutput(output: string): CompilerResults { // Only update reason if it's not already set if (!currentFailure.reason) { currentFailure.reason = reasonMatch[1]; + + // Check if this error should be suppressed after we have the reason + if (shouldSuppressError(currentFailure)) { + currentFailure = null; + continue; + } + failure.set(getUniqueFileKey(currentFailure), currentFailure); } currentFailure = null; @@ -245,6 +264,11 @@ function parseCombinedOutput(output: string): CompilerResults { return {success: successSet, failures: failure}; } +function shouldSuppressError(failure: CompilerFailure): boolean { + // Check if the error reason matches any of the suppressed error patterns + return SUPPRESSED_COMPILER_ERRORS.some((suppressedError) => failure.reason.includes(suppressedError)); +} + function getUniqueFileKey(failure: CompilerFailure): string { return `${failure.file}:${failure.line}:${failure.column}`; } From f072428a57dc3b962bd149b9750c2236aedff384 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 8 Oct 2025 17:34:56 +0100 Subject: [PATCH 02/78] refactor: rename parsing function --- scripts/react-compiler-compliance-check.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index cb9b9765ba7f..3d39a30d8f30 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -101,7 +101,7 @@ function runCompilerHealthcheck(src?: string): CompilerResults { }); // Parse and then normalize via Set/Map to ensure true uniqueness - const parsed = parseCombinedOutput(output); + const parsed = parseHealthcheckOutput(output); // Use Set to deduplicate success entries const successSet = new Set(parsed.success); @@ -124,7 +124,7 @@ function runCompilerHealthcheck(src?: string): CompilerResults { return {success: successSet, failures: failureMap}; } -function parseCombinedOutput(output: string): CompilerResults { +function parseHealthcheckOutput(output: string): CompilerResults { const lines = output.split('\n'); const successSet = new Set(); const failure = new Map(); From fd65f7feb46c67a298789efef3c63e47cfca215e Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 8 Oct 2025 17:36:47 +0100 Subject: [PATCH 03/78] refactor: extract regex patterns --- scripts/react-compiler-compliance-check.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 3d39a30d8f30..aafff4610222 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -22,6 +22,20 @@ const SUPPRESSED_COMPILER_ERRORS = [ '(BuildHIR::lowerExpression) Expected Identifier, got MemberExpression key in ObjectExpression', ] as const satisfies string[]; +const REGEX_PATTERNS = { + // Parse successful compilation from verbose output + SUCCESS_COMPILATION: /Successfully compiled (?:hook|component) \[([^\]]+)\]\(([^)]+)\)/, + + // Parse failed compilation with file, location, and reason all on one line + FAILURE_WITH_REASON: /Failed to compile ([^:]+):(\d+):(\d+)\. Reason: (.+)/, + + // Parse failed compilation with file and location only (fallback) + FAILURE_WITHOUT_REASON: /Failed to compile ([^:]+):(\d+):(\d+)\./, + + // Parse reason line (fallback for multi-line reasons) + REASON_LINE: /Reason: (.+)/, +} as const satisfies Record; + type HealthcheckJsonResults = { success: string[]; failures: CompilerFailure; @@ -161,7 +175,7 @@ function parseHealthcheckOutput(output: string): CompilerResults { for (const line of lines) { // Parse successful compilation from verbose output - const successMatch = line.match(/Successfully compiled (?:hook|component) \[([^\]]+)\]\(([^)]+)\)/); + const successMatch = line.match(REGEX_PATTERNS.SUCCESS_COMPILATION); if (successMatch) { const filePath = successMatch[2]; successSet.add(filePath); @@ -169,7 +183,7 @@ function parseHealthcheckOutput(output: string): CompilerResults { } // Parse failed compilation with file, location, and reason all on one line - const failureWithReasonMatch = line.match(/Failed to compile ([^:]+):(\d+):(\d+)\. Reason: (.+)/); + const failureWithReasonMatch = line.match(REGEX_PATTERNS.FAILURE_WITH_REASON); if (failureWithReasonMatch) { const newFailure = { file: failureWithReasonMatch[1], @@ -195,7 +209,7 @@ function parseHealthcheckOutput(output: string): CompilerResults { } // Parse failed compilation with file and location only (fallback) - const failureMatch = line.match(/Failed to compile ([^:]+):(\d+):(\d+)\./); + const failureMatch = line.match(REGEX_PATTERNS.FAILURE_WITHOUT_REASON); if (failureMatch) { // Save previous failure if exists if (currentFailure) { @@ -233,7 +247,7 @@ function parseHealthcheckOutput(output: string): CompilerResults { } // Parse reason line (fallback for multi-line reasons) - const reasonMatch = line.match(/Reason: (.+)/); + const reasonMatch = line.match(REGEX_PATTERNS.REASON_LINE); if (reasonMatch && currentFailure) { // Only update reason if it's not already set if (!currentFailure.reason) { From 95c34bbc3c0d7e58464599558414cc1623ad9d1d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 8 Oct 2025 17:42:07 +0100 Subject: [PATCH 04/78] feat: also use parsed failures from JSON --- scripts/react-compiler-compliance-check.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index aafff4610222..2b2081371ee8 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -38,7 +38,7 @@ const REGEX_PATTERNS = { type HealthcheckJsonResults = { success: string[]; - failures: CompilerFailure; + failures: CompilerFailure[]; }; type CompilerResults = { @@ -162,7 +162,24 @@ function parseHealthcheckOutput(output: string): CompilerResults { const jsonLines = lines.slice(jsonStart, jsonEnd + 1); const jsonStr = jsonLines.join('\n'); const jsonResult = JSON.parse(jsonStr) as HealthcheckJsonResults; + + // Process successful compilations from JSON jsonResult.success.forEach((success) => successSet.add(success)); + + // Process failures from JSON + jsonResult.failures.forEach((jsonFailure) => { + // Skip if this error should be suppressed + if (shouldSuppressError(jsonFailure)) { + return; + } + + const key = getUniqueFileKey(jsonFailure); + // Only add if not already exists, or if existing one has no reason + const existing = failure.get(key); + if (!existing?.reason) { + failure.set(key, jsonFailure); + } + }); } catch (error) { warn('Failed to parse JSON from combined output:', error); } From e6224d965d3b0c94389008022b7a55b987d73526 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 8 Oct 2025 18:13:45 +0100 Subject: [PATCH 05/78] refactor: restructure parsing logic and simplify --- scripts/react-compiler-compliance-check.ts | 246 ++++++++++----------- 1 file changed, 116 insertions(+), 130 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 2b2081371ee8..abfb54717ad7 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -22,18 +22,11 @@ const SUPPRESSED_COMPILER_ERRORS = [ '(BuildHIR::lowerExpression) Expected Identifier, got MemberExpression key in ObjectExpression', ] as const satisfies string[]; -const REGEX_PATTERNS = { - // Parse successful compilation from verbose output - SUCCESS_COMPILATION: /Successfully compiled (?:hook|component) \[([^\]]+)\]\(([^)]+)\)/, - - // Parse failed compilation with file, location, and reason all on one line +const VERBOSE_OUTPUT_LINE_REGEXES = { + SUCCESS: /Successfully compiled (?:hook|component) \[([^\]]+)\]\(([^)]+)\)/, FAILURE_WITH_REASON: /Failed to compile ([^:]+):(\d+):(\d+)\. Reason: (.+)/, - - // Parse failed compilation with file and location only (fallback) FAILURE_WITHOUT_REASON: /Failed to compile ([^:]+):(\d+):(\d+)\./, - - // Parse reason line (fallback for multi-line reasons) - REASON_LINE: /Reason: (.+)/, + REASON: /Reason: (.+)/, } as const satisfies Record; type HealthcheckJsonResults = { @@ -50,7 +43,7 @@ type CompilerFailure = { file: string; line?: number; column?: number; - reason: string; + reason?: string; }; function check(filesToCheck?: string[], shouldGenerateReport = false) { @@ -114,36 +107,40 @@ function runCompilerHealthcheck(src?: string): CompilerResults { cwd: process.cwd(), }); - // Parse and then normalize via Set/Map to ensure true uniqueness - const parsed = parseHealthcheckOutput(output); - - // Use Set to deduplicate success entries - const successSet = new Set(parsed.success); - - // Use Map keyed by unique file key to deduplicate failures - const failureMap = new Map(); - parsed.failures.forEach((failure) => { - const key = getUniqueFileKey(failure); - // Prefer the first occurrence that has a reason - const existing = failureMap.get(key); - if (!existing) { - failureMap.set(key, failure); - return; - } - if (!existing.reason && failure.reason) { - failureMap.set(key, failure); - } - }); - - return {success: successSet, failures: failureMap}; + // // Use Map keyed by unique file key to deduplicate failures + // const failureMap = new Map(); + // results.failures.forEach((failure) => { + // const key = getUniqueFileKey(failure); + // // Prefer the first occurrence that has a reason + // const existing = failureMap.get(key); + // if (!existing) { + // failureMap.set(key, failure); + // return; + // } + // if (!existing.reason && failure.reason) { + // failureMap.set(key, failure); + // } + // }); + + const results = parseHealthcheckOutput(output); + return results; } function parseHealthcheckOutput(output: string): CompilerResults { const lines = output.split('\n'); - const successSet = new Set(); - const failure = new Map(); - // First, try to extract JSON from the output + const initialResults: CompilerResults = { + success: new Set(), + failures: new Map(), + }; + + const resultsAfterJson = parseJsonOutput(lines, initialResults); + const finalResults = parseVerboseOutput(lines, resultsAfterJson); + + return finalResults; +} + +function parseJsonOutput(lines: string[], results: CompilerResults): CompilerResults { let jsonStart = -1; let jsonEnd = -1; for (let i = 0; i < lines.length; i++) { @@ -156,152 +153,141 @@ function parseHealthcheckOutput(output: string): CompilerResults { } } - // Parse JSON if found - if (jsonStart !== -1 && jsonEnd !== -1) { - try { - const jsonLines = lines.slice(jsonStart, jsonEnd + 1); - const jsonStr = jsonLines.join('\n'); - const jsonResult = JSON.parse(jsonStr) as HealthcheckJsonResults; - - // Process successful compilations from JSON - jsonResult.success.forEach((success) => successSet.add(success)); - - // Process failures from JSON - jsonResult.failures.forEach((jsonFailure) => { - // Skip if this error should be suppressed - if (shouldSuppressError(jsonFailure)) { - return; - } - - const key = getUniqueFileKey(jsonFailure); - // Only add if not already exists, or if existing one has no reason - const existing = failure.get(key); - if (!existing?.reason) { - failure.set(key, jsonFailure); - } - }); - } catch (error) { - warn('Failed to parse JSON from combined output:', error); - } - } else { + if (jsonStart === -1 || jsonEnd === -1) { warn('No JSON found in combined output, parsing verbose text only'); + + return results; + } + + // Parse JSON if found + try { + const jsonLines = lines.slice(jsonStart, jsonEnd + 1); + const jsonStr = jsonLines.join('\n'); + const jsonResult = JSON.parse(jsonStr) as HealthcheckJsonResults; + + // Process successful compilations from JSON + jsonResult.success.forEach((success) => results.success.add(success)); + + // Process failures from JSON + jsonResult.failures.forEach((newFailure) => { + if (shouldSuppressCompilerError(newFailure.reason)) { + return; + } + + const key = getUniqueFileKey(newFailure); + + // Only add if not already exists, or if existing one has no reason + const existing = results.failures.get(key); + if (!existing?.reason) { + results.failures.set(key, newFailure); + } + }); + } catch (error) { + warn('Failed to parse JSON from combined react-compiler-healthcheck output:', error); } - // Parse verbose output for detailed failure information - let currentFailure: CompilerFailure | null = null; + return results; +} + +function parseVerboseOutput(lines: string[], results: CompilerResults): CompilerResults { + let currentFailureWithoutReason: CompilerFailure; for (const line of lines) { - // Parse successful compilation from verbose output - const successMatch = line.match(REGEX_PATTERNS.SUCCESS_COMPILATION); + // Parse successful file paths + const successMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.SUCCESS); if (successMatch) { const filePath = successMatch[2]; - successSet.add(filePath); + results.success.add(filePath); continue; } - // Parse failed compilation with file, location, and reason all on one line - const failureWithReasonMatch = line.match(REGEX_PATTERNS.FAILURE_WITH_REASON); + // Parse failed file paths with file, location, and reason all on one line + const failureWithReasonMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.FAILURE_WITH_REASON); if (failureWithReasonMatch) { - const newFailure = { + const newFailure: CompilerFailure = { file: failureWithReasonMatch[1], line: parseInt(failureWithReasonMatch[2], 10), column: parseInt(failureWithReasonMatch[3], 10), reason: failureWithReasonMatch[4], }; - // Skip if this error should be suppressed - if (shouldSuppressError(newFailure)) { - currentFailure = null; + // If we already have a reason, we don't want to set the reason again + currentFailureWithoutReason = null; + + if (shouldSuppressCompilerError(newFailure.reason)) { continue; } - const key = getUniqueFileKey(newFailure); // Only add if not already exists, or if existing one has no reason - const existing = failure.get(key); + const key = getUniqueFileKey(newFailure); + const existing = results.failures.get(key); if (!existing?.reason) { - failure.set(key, newFailure); + results.failures.set(key, newFailure); } - currentFailure = null; + continue; } // Parse failed compilation with file and location only (fallback) - const failureMatch = line.match(REGEX_PATTERNS.FAILURE_WITHOUT_REASON); + const failureMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.FAILURE_WITHOUT_REASON); if (failureMatch) { - // Save previous failure if exists - if (currentFailure) { - const key = getUniqueFileKey(currentFailure); - const existing = failure.get(key); - if (!existing?.reason) { - failure.set(key, currentFailure); - } - } - - const key = getUniqueFileKey({ + const newFailure: CompilerFailure = { file: failureMatch[1], line: parseInt(failureMatch[2], 10), column: parseInt(failureMatch[3], 10), - reason: '', - }); + }; // Only create new failure if it doesn't exist - if (failure.has(key)) { - // Use existing failure if it exists - const existingFailure = failure.get(key); - if (existingFailure) { - currentFailure = existingFailure; - } + const key = getUniqueFileKey(newFailure); + if (results.failures.has(key)) { continue; } - currentFailure = { - file: failureMatch[1], - line: parseInt(failureMatch[2], 10), - column: parseInt(failureMatch[3], 10), - reason: '', - }; + results.failures.set(key, newFailure); + currentFailureWithoutReason = newFailure; continue; } // Parse reason line (fallback for multi-line reasons) - const reasonMatch = line.match(REGEX_PATTERNS.REASON_LINE); - if (reasonMatch && currentFailure) { - // Only update reason if it's not already set - if (!currentFailure.reason) { - currentFailure.reason = reasonMatch[1]; + const reasonMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.REASON); + if (reasonMatch && currentFailureWithoutReason) { + const reason = reasonMatch[1]; - // Check if this error should be suppressed after we have the reason - if (shouldSuppressError(currentFailure)) { - currentFailure = null; - continue; - } + // After we have parsed a file with reason only, we can always clear the current failure + currentFailureWithoutReason = null; - failure.set(getUniqueFileKey(currentFailure), currentFailure); + // Only update reason if it's not already set + if (currentFailureWithoutReason.reason) { + continue; } - currentFailure = null; - continue; - } - } - // Add any remaining failure - if (currentFailure) { - const key = getUniqueFileKey(currentFailure); - const existing = failure.get(key); - if (!existing?.reason) { - failure.set(key, currentFailure); + if (shouldSuppressCompilerError(reason)) { + continue; + } + + const newFailure: CompilerFailure = { + file: currentFailureWithoutReason.file, + line: currentFailureWithoutReason.line, + column: currentFailureWithoutReason.column, + reason, + }; + + results.failures.set(getUniqueFileKey(newFailure), newFailure); + + continue; } } - return {success: successSet, failures: failure}; + return results; } -function shouldSuppressError(failure: CompilerFailure): boolean { +function shouldSuppressCompilerError(reason: string): boolean { // Check if the error reason matches any of the suppressed error patterns - return SUPPRESSED_COMPILER_ERRORS.some((suppressedError) => failure.reason.includes(suppressedError)); + return SUPPRESSED_COMPILER_ERRORS.some((suppressedError) => reason.includes(suppressedError)); } -function getUniqueFileKey(failure: CompilerFailure): string { - return `${failure.file}:${failure.line}:${failure.column}`; +function getUniqueFileKey({file, line, column}: CompilerFailure): string { + return `${file}:${line}:${column}`; } function createFilesGlob(filesToCheck?: string[]): string | undefined { From 6ec2eb341b73e0a7eb252444c14cf8453f494a9f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Thu, 9 Oct 2025 12:01:11 +0100 Subject: [PATCH 06/78] fix: TS errors --- scripts/react-compiler-compliance-check.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index abfb54717ad7..4de58ecaaa46 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -190,7 +190,7 @@ function parseJsonOutput(lines: string[], results: CompilerResults): CompilerRes } function parseVerboseOutput(lines: string[], results: CompilerResults): CompilerResults { - let currentFailureWithoutReason: CompilerFailure; + let currentFailureWithoutReason: CompilerFailure | null = null; for (const line of lines) { // Parse successful file paths @@ -253,15 +253,14 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler if (reasonMatch && currentFailureWithoutReason) { const reason = reasonMatch[1]; - // After we have parsed a file with reason only, we can always clear the current failure - currentFailureWithoutReason = null; - // Only update reason if it's not already set if (currentFailureWithoutReason.reason) { + currentFailureWithoutReason = null; continue; } if (shouldSuppressCompilerError(reason)) { + currentFailureWithoutReason = null; continue; } @@ -274,6 +273,7 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler results.failures.set(getUniqueFileKey(newFailure), newFailure); + currentFailureWithoutReason = null; continue; } } @@ -281,7 +281,7 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler return results; } -function shouldSuppressCompilerError(reason: string): boolean { +function shouldSuppressCompilerError(reason: string | undefined): boolean { // Check if the error reason matches any of the suppressed error patterns return SUPPRESSED_COMPILER_ERRORS.some((suppressedError) => reason.includes(suppressedError)); } From 67a2a82e4d9ca8d824edd46d65a9af4e61178a78 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 13 Oct 2025 16:13:21 +0100 Subject: [PATCH 07/78] fix: add nullish check to `shouldSuppressCompilerError` --- scripts/react-compiler-compliance-check.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 4de58ecaaa46..bc7a26f19c63 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -282,6 +282,10 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler } function shouldSuppressCompilerError(reason: string | undefined): boolean { + if (!reason) { + return false; + } + // Check if the error reason matches any of the suppressed error patterns return SUPPRESSED_COMPILER_ERRORS.some((suppressedError) => reason.includes(suppressedError)); } From 124fca6b3137aab2bc4bb50bafde0441875a3757 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 13 Oct 2025 16:49:15 +0100 Subject: [PATCH 08/78] refactor: add more cli options and refactor Git tools --- scripts/react-compiler-compliance-check.ts | 47 +++++++++++++++++----- scripts/utils/Git.ts | 15 ++----- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index bc7a26f19c63..e6411e7a32d4 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -46,7 +46,18 @@ type CompilerFailure = { reason?: string; }; -function check(filesToCheck?: string[], shouldGenerateReport = false) { +type CommonCheckOptions = { + remote?: string; + shouldGenerateReport?: boolean; + reportFileName?: string; + shouldFilterByDiff?: boolean; +}; + +type CheckOptions = CommonCheckOptions & { + filesToCheck?: string[]; +}; + +function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote}: CheckOptions) { if (filesToCheck) { info(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); } else { @@ -54,7 +65,8 @@ function check(filesToCheck?: string[], shouldGenerateReport = false) { } const src = createFilesGlob(filesToCheck); - const results = runCompilerHealthcheck(src); + let results = runCompilerHealthcheck(src); + const isPassed = results.failures.size === 0; if (isPassed) { @@ -65,17 +77,22 @@ function check(filesToCheck?: string[], shouldGenerateReport = false) { printFailureSummary(results); if (shouldGenerateReport) { - generateReport(results, DEFAULT_REPORT_FILENAME); + generateReport(results, reportFileName); } return false; } -async function checkChangedFiles(remote: string): Promise { +type CheckChangedFilesOptions = CommonCheckOptions & { + reportFileName?: string; +}; + +async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOptions): Promise { info('Checking changed files for React Compiler compliance...'); try { - const changedFiles = await Git.getChangedFiles(remote); + const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); + const changedFiles = await Git.getChangedFiles(mainBaseCommitHash); const filesToCheck = [...new Set(changedFiles)]; if (filesToCheck.length === 0) { @@ -83,7 +100,7 @@ async function checkChangedFiles(remote: string): Promise { return true; } - return check(filesToCheck); + return check({filesToCheck, ...restOptions}); } catch (error) { if (error instanceof Error && error.message === GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE) { logError(`Could not fetch from remote ${remote}. If your base remote is not ${remote}, please specify another remote with the --remote flag.`); @@ -403,8 +420,18 @@ async function main() { supersedes: ['check-changed'], default: 'origin', }, + reportFileName: { + description: 'File name to save the report to', + required: false, + default: DEFAULT_REPORT_FILENAME, + }, }, flags: { + filterByDiff: { + description: 'Filter the files to check by the diff between the current commit/PR and the main branch', + required: false, + default: false, + }, report: { description: 'Generate a report of the results', required: false, @@ -414,17 +441,17 @@ async function main() { }); const {command, file} = cli.positionalArgs; - const {remote} = cli.namedArgs; - const {report: shouldGenerateReport} = cli.flags; + const {remote, reportFileName} = cli.namedArgs; + const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff} = cli.flags; let isPassed = false; try { switch (command) { case 'check': - isPassed = Checker.check(file !== '' ? [file] : undefined, shouldGenerateReport); + isPassed = Checker.check({filesToCheck: file !== '' ? [file] : undefined, shouldGenerateReport, reportFileName, shouldFilterByDiff}); break; case 'check-changed': - isPassed = await Checker.checkChangedFiles(remote); + isPassed = await Checker.checkChangedFiles({remote, shouldGenerateReport, reportFileName, shouldFilterByDiff}); break; default: logError(`Unknown command: ${String(command)}`); diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 15100b948d2d..08dd799943d1 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -316,8 +316,7 @@ class Git { } } - static getMainBaseCommitHash(remote: string): string { - // Fetch the main branch from the specified remote to ensure it's available + static getMainBranchCommitHash(remote = 'origin'): string { try { execSync(`git fetch ${remote} main --no-tags --depth=1 -q`, {encoding: 'utf8'}); } catch (error) { @@ -366,7 +365,7 @@ class Git { return mergeBaseHash; } - static async getChangedFiles(remote: string): Promise { + static async getChangedFiles(fromRef: string, toRef = 'HEAD'): Promise { if (IS_CI) { const {data: changedFiles} = await GitHubUtils.octokit.pulls.listFiles({ owner: 'Expensify', @@ -379,15 +378,9 @@ class Git { } try { - // Get files changed in the current branch/commit - const mainBaseCommitHash = this.getMainBaseCommitHash(remote); - // Get the diff output and check status - const gitDiffOutput = execSync(`git diff --diff-filter=AMR --name-only ${mainBaseCommitHash} HEAD`, { - encoding: 'utf8', - }); - - const files = gitDiffOutput.trim().split('\n'); + const diffResult = this.diff(fromRef, toRef); + const files = diffResult.files.map((file) => file.filePath); return files; } catch (error) { if (error instanceof Error && error.message === GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE) { From 8dc520483802716e8ca30787bed6220cd3dfea57 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 13 Oct 2025 16:49:25 +0100 Subject: [PATCH 09/78] feat: filter by git diff --- scripts/react-compiler-compliance-check.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index e6411e7a32d4..1fbeacda0c15 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -67,6 +67,12 @@ function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEF const src = createFilesGlob(filesToCheck); let results = runCompilerHealthcheck(src); + if (shouldFilterByDiff) { + const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); + const headCommitHash = 'HEAD'; + const diffCommits = {from: mainBaseCommitHash, to: headCommitHash}; + results = filterResultsByDiff(results, diffCommits); + } const isPassed = results.failures.size === 0; if (isPassed) { From 2091e2a050938d897cd4c53dc3bd503866092ada Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 13 Oct 2025 16:55:14 +0100 Subject: [PATCH 10/78] feat: add `filterResultsByDiff` util function (AI) --- scripts/react-compiler-compliance-check.ts | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 1fbeacda0c15..211bf5febf0b 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -12,6 +12,7 @@ import {join} from 'path'; import type {TupleToUnion} from 'type-fest'; import CLI from './utils/CLI'; import Git, {GIT_ERRORS} from './utils/Git'; +import type {DiffResult} from './utils/Git'; import {bold, info, log, error as logError, success as logSuccess, note, warn} from './utils/Logger'; const DEFAULT_REPORT_FILENAME = 'react-compiler-report.json'; @@ -329,6 +330,83 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { return `**/+(${filesToCheck.join('|')})`; } +/** + * Filters compiler results to only include failures for lines that were changed in the git diff. + * This helps focus on new issues introduced by the current changes rather than pre-existing issues. + * + * @param results - The compiler results to filter + * @param diffCommits - The commit range to diff (from and to) + * @returns Filtered compiler results containing only failures in changed lines + */ +function filterResultsByDiff(results: CompilerResults, diffCommits: {from: string; to: string}): CompilerResults { + info(`Filtering results by diff between ${diffCommits.from} and ${diffCommits.to}...`); + + // Get the diff between the two commits + const diffResult: DiffResult = Git.diff(diffCommits.from, diffCommits.to); + + // If there are no changes, return empty results + if (!diffResult.hasChanges) { + return { + success: new Set(), + failures: new Map(), + }; + } + + // Create a map of file paths to changed line numbers for quick lookup + const changedLinesMap = new Map>(); + for (const file of diffResult.files) { + const changedLines = new Set(); + + // Include all added lines + file.addedLines.forEach((line) => changedLines.add(line)); + + // Include all modified lines + file.modifiedLines.forEach((line) => changedLines.add(line)); + + changedLinesMap.set(file.filePath, changedLines); + } + + // Filter failures to only include those on changed lines + const filteredFailures = new Map(); + results.failures.forEach((failure, key) => { + const changedLines = changedLinesMap.get(failure.file); + + // If the file is not in the diff, skip this failure + if (!changedLines) { + return; + } + + // If the failure has a line number, check if it's in the changed lines + if (failure.line !== undefined) { + const isLineChanged = changedLines.has(failure.line); + if (isLineChanged) { + filteredFailures.set(key, failure); + } + return; + } + + // If there's no line number, include the failure if the file has changes + filteredFailures.set(key, failure); + }); + + // Filter success set to only include files that are in the diff + const changedFiles = new Set(diffResult.files.map((file) => file.filePath)); + const filteredSuccess = new Set(); + results.success.forEach((file) => { + if (!changedFiles.has(file)) { + return; + } + filteredSuccess.add(file); + }); + + info(`Filtered ${results.failures.size} failures to ${filteredFailures.size} failures in changed lines.`); + + return { + success: filteredSuccess, + failures: filteredFailures, + }; +} + function printFailureSummary({success, failures}: CompilerResults): void { // const failedFileNames = getDistinctFileNames(Array.from(failures.values()), (f) => f.file, fileToCheck); From eb67186f88af4c82f9a4bac93502fa515284daef Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 14 Oct 2025 18:11:20 +0100 Subject: [PATCH 11/78] fix: simplify Git util functions and update error handling --- scripts/react-compiler-compliance-check.ts | 12 ++---- scripts/utils/Git.ts | 44 ++++++++++------------ 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 211bf5febf0b..abe075e31603 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -11,7 +11,7 @@ import {writeFileSync} from 'fs'; import {join} from 'path'; import type {TupleToUnion} from 'type-fest'; import CLI from './utils/CLI'; -import Git, {GIT_ERRORS} from './utils/Git'; +import Git from './utils/Git'; import type {DiffResult} from './utils/Git'; import {bold, info, log, error as logError, success as logSuccess, note, warn} from './utils/Logger'; @@ -108,12 +108,7 @@ async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOpti } return check({filesToCheck, ...restOptions}); - } catch (error) { - if (error instanceof Error && error.message === GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE) { - logError(`Could not fetch from remote ${remote}. If your base remote is not ${remote}, please specify another remote with the --remote flag.`); - } - - logError('Could not determine changed files:', error); + } catch { return false; } } @@ -499,10 +494,9 @@ async function main() { ], namedArgs: { remote: { - description: 'Git remote name to use for main branch (default: origin)', + description: 'Git remote name to use for main branch (default: no remote locally and origin in CI)', required: false, supersedes: ['check-changed'], - default: 'origin', }, reportFileName: { description: 'File name to save the report to', diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 08dd799943d1..a77f45ac976c 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -2,16 +2,12 @@ import {context} from '@actions/github'; import {execSync, exec as execWithCallback} from 'child_process'; import {promisify} from 'util'; import GitHubUtils from '@github/libs/GithubUtils'; -import {error as logError} from './Logger'; +import {error as logError, warn as logWarn} from './Logger'; const exec = promisify(execWithCallback); const IS_CI = process.env.CI === 'true'; -const GIT_ERRORS = { - FAILED_TO_FETCH_FROM_REMOTE: 'Failed to fetch from remote', -} as const; - /** * Represents a single changed line in a git diff. * Only added and removed lines are tracked (context lines are skipped during parsing). @@ -316,18 +312,19 @@ class Git { } } - static getMainBranchCommitHash(remote = 'origin'): string { - try { - execSync(`git fetch ${remote} main --no-tags --depth=1 -q`, {encoding: 'utf8'}); - } catch (error) { - throw new Error(GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE); + static getMainBranchCommitHash(remote?: string): string { + // Fetch the main branch from the specified remote (or locally) to ensure it's available + if (IS_CI || remote) { + this.ensureRef('main', remote); } // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { + const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; + try { - const mergeBaseHash = execSync(`git rev-parse ${remote}/main`, {encoding: 'utf8'}).trim(); + const mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { @@ -336,24 +333,26 @@ class Git { return mergeBaseHash; } catch (error) { - logError(`Failed to get commit hash for ${remote}/main:`, error); - throw new Error(`Could not get commit hash for ${remote}/main`); + logError(`Failed to get commit hash for ${mainBaseRef}:`, error); + throw new Error(`Could not get commit hash for ${mainBaseRef}`); } } + const mainBaseRef = remote ? `${remote}/main` : 'main'; + // For local development, try to find the actual merge base let mergeBaseHash: string; try { - mergeBaseHash = execSync(`git merge-base ${remote}/main HEAD`, {encoding: 'utf8'}).trim(); - } catch (error) { + mergeBaseHash = execSync(`git merge-base ${mainBaseRef} HEAD`, {encoding: 'utf8'}).trim(); + } catch { + logWarn(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); + // If merge-base fails locally, fall back to using the remote main branch try { - mergeBaseHash = execSync(`git rev-parse ${remote}/main`, {encoding: 'utf8'}).trim(); - logError(`Warning: Could not find merge base between ${remote}/main and HEAD. Using ${remote}/main as base.`); + mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); } catch (fallbackError) { - logError(`Failed to find merge base with ${remote}/main:`, error); - logError(`Fallback also failed:`, fallbackError); - throw new Error(`Could not determine merge base with ${remote}/main`); + logError(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); + throw new Error(`Could not determine merge base with ${mainBaseRef}`); } } @@ -383,10 +382,6 @@ class Git { const files = diffResult.files.map((file) => file.filePath); return files; } catch (error) { - if (error instanceof Error && error.message === GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE) { - throw error; - } - logError('Could not determine changed files:', error); throw error; } @@ -394,5 +389,4 @@ class Git { } export default Git; -export {GIT_ERRORS}; export type {DiffResult, FileDiff, DiffHunk, DiffLine}; From 4706e9554469880f3252893e1191a0c7b90a9516 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 14 Oct 2025 18:16:44 +0100 Subject: [PATCH 12/78] fix: JSON parsing issue --- scripts/react-compiler-compliance-check.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index abe075e31603..9882fe1e7000 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -32,7 +32,7 @@ const VERBOSE_OUTPUT_LINE_REGEXES = { type HealthcheckJsonResults = { success: string[]; - failures: CompilerFailure[]; + failure: CompilerFailure[]; }; type CompilerResults = { @@ -188,7 +188,7 @@ function parseJsonOutput(lines: string[], results: CompilerResults): CompilerRes jsonResult.success.forEach((success) => results.success.add(success)); // Process failures from JSON - jsonResult.failures.forEach((newFailure) => { + jsonResult.failure.forEach((newFailure) => { if (shouldSuppressCompilerError(newFailure.reason)) { return; } From 9f3c08e8b8781ae99a907df5acffdc34ed61ff6b Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 14 Oct 2025 18:26:10 +0100 Subject: [PATCH 13/78] fix: extract type and simplify --- scripts/react-compiler-compliance-check.ts | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 9882fe1e7000..6d91b1c3cdd5 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -47,6 +47,11 @@ type CompilerFailure = { reason?: string; }; +type DiffFilteringCommits = { + from: string; + to: string; +}; + type CommonCheckOptions = { remote?: string; shouldGenerateReport?: boolean; @@ -71,8 +76,8 @@ function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEF if (shouldFilterByDiff) { const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); const headCommitHash = 'HEAD'; - const diffCommits = {from: mainBaseCommitHash, to: headCommitHash}; - results = filterResultsByDiff(results, diffCommits); + const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; + results = filterResultsByDiff(results, diffFilteringCommits); } const isPassed = results.failures.size === 0; @@ -330,14 +335,14 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * This helps focus on new issues introduced by the current changes rather than pre-existing issues. * * @param results - The compiler results to filter - * @param diffCommits - The commit range to diff (from and to) + * @param diffFilteringCommits - The commit range to diff (from and to) * @returns Filtered compiler results containing only failures in changed lines */ -function filterResultsByDiff(results: CompilerResults, diffCommits: {from: string; to: string}): CompilerResults { - info(`Filtering results by diff between ${diffCommits.from} and ${diffCommits.to}...`); +function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits): CompilerResults { + info(`Filtering results by diff between ${diffFilteringCommits.from} and ${diffFilteringCommits.to}...`); // Get the diff between the two commits - const diffResult: DiffResult = Git.diff(diffCommits.from, diffCommits.to); + const diffResult: DiffResult = Git.diff(diffFilteringCommits.from, diffFilteringCommits.to); // If there are no changes, return empty results if (!diffResult.hasChanges) { @@ -351,13 +356,8 @@ function filterResultsByDiff(results: CompilerResults, diffCommits: {from: strin const changedLinesMap = new Map>(); for (const file of diffResult.files) { const changedLines = new Set(); - - // Include all added lines file.addedLines.forEach((line) => changedLines.add(line)); - - // Include all modified lines file.modifiedLines.forEach((line) => changedLines.add(line)); - changedLinesMap.set(file.filePath, changedLines); } @@ -394,7 +394,11 @@ function filterResultsByDiff(results: CompilerResults, diffCommits: {from: strin filteredSuccess.add(file); }); - info(`Filtered ${results.failures.size} failures to ${filteredFailures.size} failures in changed lines.`); + if (filteredFailures.size === 0) { + info('No failures remain after filtering by diff.'); + } else { + info(`${filteredFailures.size} out of ${results.failures.size} files remain after filtering by diff.`); + } return { success: filteredSuccess, From 7384fd9c49054821bb55e16054252f7ad890d614 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 14 Oct 2025 18:57:58 +0100 Subject: [PATCH 14/78] feat: warn if filtering by diff and user has uncommited changes --- scripts/react-compiler-compliance-check.ts | 5 +++++ scripts/utils/Git.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 6d91b1c3cdd5..dbf692335939 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -339,6 +339,11 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * @returns Filtered compiler results containing only failures in changed lines */ function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits): CompilerResults { + // Check for uncommitted changes and warn if any exist + if (Git.hasUncommittedChanges()) { + warn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); + } + info(`Filtering results by diff between ${diffFilteringCommits.from} and ${diffFilteringCommits.to}...`); // Get the diff between the two commits diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index a77f45ac976c..0be93c4dbffb 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -364,6 +364,23 @@ class Git { return mergeBaseHash; } + /** + * Check if there are any uncommitted changes (both staged and unstaged). + * + * @returns true if there are uncommitted changes, false otherwise + */ + static hasUncommittedChanges(): boolean { + try { + const status = execSync('git status --porcelain', { + encoding: 'utf8', + cwd: process.cwd(), + }).trim(); + return status.length > 0; + } catch (error) { + return false; + } + } + static async getChangedFiles(fromRef: string, toRef = 'HEAD'): Promise { if (IS_CI) { const {data: changedFiles} = await GitHubUtils.octokit.pulls.listFiles({ From ffcc2226a03aa17a2caff05072f6102feaf9c089 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 14 Oct 2025 18:58:28 +0100 Subject: [PATCH 15/78] refactor: alias log functions --- scripts/react-compiler-compliance-check.ts | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index dbf692335939..2ac99240c35d 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -13,7 +13,7 @@ import type {TupleToUnion} from 'type-fest'; import CLI from './utils/CLI'; import Git from './utils/Git'; import type {DiffResult} from './utils/Git'; -import {bold, info, log, error as logError, success as logSuccess, note, warn} from './utils/Logger'; +import {log, bold as logBold, error as logError, info as logInfo, note as logNote, success as logSuccess, warn as logWarn} from './utils/Logger'; const DEFAULT_REPORT_FILENAME = 'react-compiler-report.json'; @@ -65,9 +65,9 @@ type CheckOptions = CommonCheckOptions & { function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote}: CheckOptions) { if (filesToCheck) { - info(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); + logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); } else { - info('Running React Compiler check for all files...'); + logInfo('Running React Compiler check for all files...'); } const src = createFilesGlob(filesToCheck); @@ -100,7 +100,7 @@ type CheckChangedFilesOptions = CommonCheckOptions & { }; async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOptions): Promise { - info('Checking changed files for React Compiler compliance...'); + logInfo('Checking changed files for React Compiler compliance...'); try { const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); @@ -178,7 +178,7 @@ function parseJsonOutput(lines: string[], results: CompilerResults): CompilerRes } if (jsonStart === -1 || jsonEnd === -1) { - warn('No JSON found in combined output, parsing verbose text only'); + logWarn('No JSON found in combined output, parsing verbose text only'); return results; } @@ -207,7 +207,7 @@ function parseJsonOutput(lines: string[], results: CompilerResults): CompilerRes } }); } catch (error) { - warn('Failed to parse JSON from combined react-compiler-healthcheck output:', error); + logWarn('Failed to parse JSON from combined react-compiler-healthcheck output:', error); } return results; @@ -341,10 +341,10 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits): CompilerResults { // Check for uncommitted changes and warn if any exist if (Git.hasUncommittedChanges()) { - warn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); + logWarn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); } - info(`Filtering results by diff between ${diffFilteringCommits.from} and ${diffFilteringCommits.to}...`); + logInfo(`Filtering results by diff between ${diffFilteringCommits.from} and ${diffFilteringCommits.to}...`); // Get the diff between the two commits const diffResult: DiffResult = Git.diff(diffFilteringCommits.from, diffFilteringCommits.to); @@ -400,9 +400,9 @@ function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: Dif }); if (filteredFailures.size === 0) { - info('No failures remain after filtering by diff.'); + logInfo('No failures remain after filtering by diff.'); } else { - info(`${filteredFailures.size} out of ${results.failures.size} files remain after filtering by diff.`); + logInfo(`${filteredFailures.size} out of ${results.failures.size} files remain after filtering by diff.`); } return { @@ -433,9 +433,9 @@ function printFailureSummary({success, failures}: CompilerResults): void { // Print unique failures for the files that were checked failures.forEach((failure) => { const location = failure.line && failure.column ? `:${failure.line}:${failure.column}` : ''; - bold(`${failure.file}${location}`); + logBold(`${failure.file}${location}`); if (failure.reason) { - note(`${tab}${failure.reason}`); + logNote(`${tab}${failure.reason}`); } }); @@ -445,7 +445,7 @@ function printFailureSummary({success, failures}: CompilerResults): void { function generateReport(results: CompilerResults, outputFileName = DEFAULT_REPORT_FILENAME): void { log('\n'); - info('Creating React Compiler Compliance Check report:'); + logInfo('Creating React Compiler Compliance Check report:'); // Save detailed report const reportFile = join(process.cwd(), outputFileName); From 38a624a96843b7037697a0d666ce0d891e737d09 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 14 Oct 2025 18:59:04 +0100 Subject: [PATCH 16/78] Update AddPlaidBankAccount.tsx --- src/components/AddPlaidBankAccount.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index 4c50576b5417..a549d55671bd 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -80,6 +80,7 @@ function AddPlaidBankAccount({ const defaultSelectedPlaidAccountID = defaultSelectedPlaidAccount?.plaidAccountID; const defaultSelectedPlaidAccountMask = plaidBankAccounts.find((account) => account.plaidAccountID === selectedPlaidAccountID)?.mask ?? ''; const subscribedKeyboardShortcuts = useRef void>>([]); + subscribedKeyboardShortcuts.current = []; const previousNetworkState = useRef(undefined); const [selectedPlaidAccountMask, setSelectedPlaidAccountMask] = useState(defaultSelectedPlaidAccountMask); const [plaidLinkToken] = useOnyx(ONYXKEYS.PLAID_LINK_TOKEN, {canBeMissing: true, initWithStoredValues: false}); From 74687dcc7157cfaf2cacc4e2eaeefcef4575885f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 11:59:23 +0100 Subject: [PATCH 17/78] fix: JSON parsing --- scripts/react-compiler-compliance-check.ts | 50 ++++++++-------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 2ac99240c35d..0206fab46360 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -32,7 +32,7 @@ const VERBOSE_OUTPUT_LINE_REGEXES = { type HealthcheckJsonResults = { success: string[]; - failure: CompilerFailure[]; + failure: string[]; }; type CompilerResults = { @@ -131,21 +131,6 @@ function runCompilerHealthcheck(src?: string): CompilerResults { cwd: process.cwd(), }); - // // Use Map keyed by unique file key to deduplicate failures - // const failureMap = new Map(); - // results.failures.forEach((failure) => { - // const key = getUniqueFileKey(failure); - // // Prefer the first occurrence that has a reason - // const existing = failureMap.get(key); - // if (!existing) { - // failureMap.set(key, failure); - // return; - // } - // if (!existing.reason && failure.reason) { - // failureMap.set(key, failure); - // } - // }); - const results = parseHealthcheckOutput(output); return results; } @@ -158,8 +143,8 @@ function parseHealthcheckOutput(output: string): CompilerResults { failures: new Map(), }; - const resultsAfterJson = parseJsonOutput(lines, initialResults); - const finalResults = parseVerboseOutput(lines, resultsAfterJson); + const verboseResults = parseVerboseOutput(lines, initialResults); + const finalResults = parseJsonOutput(lines, verboseResults); return finalResults; } @@ -190,21 +175,23 @@ function parseJsonOutput(lines: string[], results: CompilerResults): CompilerRes const jsonResult = JSON.parse(jsonStr) as HealthcheckJsonResults; // Process successful compilations from JSON - jsonResult.success.forEach((success) => results.success.add(success)); + jsonResult.success.forEach((successfulFile) => results.success.add(successfulFile)); // Process failures from JSON - jsonResult.failure.forEach((newFailure) => { - if (shouldSuppressCompilerError(newFailure.reason)) { + jsonResult.failure.forEach((failedFile) => { + // Get all failures for this file (all lines and columns) + const fileFailures = Array.from(results.failures.entries()).filter(([, failure]) => failure.file === failedFile); + + // Only add JSON file failure if no failure for this file exists already (all lines and columns) + if (fileFailures.length > 0) { return; } + const newFailure: CompilerFailure = { + file: failedFile, + }; const key = getUniqueFileKey(newFailure); - - // Only add if not already exists, or if existing one has no reason - const existing = results.failures.get(key); - if (!existing?.reason) { - results.failures.set(key, newFailure); - } + results.failures.set(key, newFailure); }); } catch (error) { logWarn('Failed to parse JSON from combined react-compiler-healthcheck output:', error); @@ -315,7 +302,10 @@ function shouldSuppressCompilerError(reason: string | undefined): boolean { } function getUniqueFileKey({file, line, column}: CompilerFailure): string { - return `${file}:${line}:${column}`; + const isLineSet = line !== undefined; + const isLineAndColumnSet = isLineSet && column !== undefined; + + return file + (isLineSet ? `:${line}` : '') + (isLineAndColumnSet ? `:${column}` : ''); } function createFilesGlob(filesToCheck?: string[]): string | undefined { @@ -434,9 +424,7 @@ function printFailureSummary({success, failures}: CompilerResults): void { failures.forEach((failure) => { const location = failure.line && failure.column ? `:${failure.line}:${failure.column}` : ''; logBold(`${failure.file}${location}`); - if (failure.reason) { - logNote(`${tab}${failure.reason}`); - } + logNote(`${tab}${failure.reason ?? 'No reason provided'}`); }); log(); From 24c20be0a0092482f30c0acf40679c8c08c2f84f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 12:02:23 +0100 Subject: [PATCH 18/78] feat: filter react compiler compliance results by by git diff in check --- .github/workflows/react-compiler-compliance.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/react-compiler-compliance.yml b/.github/workflows/react-compiler-compliance.yml index 3afcdf1bbc1e..8327139783d7 100644 --- a/.github/workflows/react-compiler-compliance.yml +++ b/.github/workflows/react-compiler-compliance.yml @@ -5,7 +5,7 @@ on: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] - paths: ['**.tsx'] + paths: ["**.tsx"] concurrency: group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-react-compiler-compliance @@ -25,7 +25,7 @@ jobs: uses: ./.github/actions/composite/setupNode - name: Run React Compiler Compliance Check - run: npm run react-compiler-compliance-check check-changed + run: npm run react-compiler-compliance-check check-changed --filterByDiff env: CI: true GITHUB_TOKEN: ${{ github.token }} From 31182d89d77f0774028f51b01d3518e3ad337cdf Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 12:18:45 +0100 Subject: [PATCH 19/78] feat: allow printing successes --- scripts/react-compiler-compliance-check.ts | 53 ++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 0206fab46360..4b5bdc328dfd 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -57,13 +57,18 @@ type CommonCheckOptions = { shouldGenerateReport?: boolean; reportFileName?: string; shouldFilterByDiff?: boolean; + shouldPrintSuccesses?: boolean; +}; + +type PrintResultsOptions = { + shouldPrintSuccesses: boolean; }; type CheckOptions = CommonCheckOptions & { filesToCheck?: string[]; }; -function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote}: CheckOptions) { +function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote, shouldPrintSuccesses = false}: CheckOptions) { if (filesToCheck) { logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); } else { @@ -77,7 +82,7 @@ function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEF const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); const headCommitHash = 'HEAD'; const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; - results = filterResultsByDiff(results, diffFilteringCommits); + results = filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); } const isPassed = results.failures.size === 0; @@ -86,7 +91,7 @@ function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEF return true; } - printFailureSummary(results); + printResults(results, {shouldPrintSuccesses}); if (shouldGenerateReport) { generateReport(results, reportFileName); @@ -328,7 +333,7 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * @param diffFilteringCommits - The commit range to diff (from and to) * @returns Filtered compiler results containing only failures in changed lines */ -function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits): CompilerResults { +function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): CompilerResults { // Check for uncommitted changes and warn if any exist if (Git.hasUncommittedChanges()) { logWarn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); @@ -381,27 +386,35 @@ function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: Dif // Filter success set to only include files that are in the diff const changedFiles = new Set(diffResult.files.map((file) => file.filePath)); - const filteredSuccess = new Set(); + const filteredSuccesses = new Set(); results.success.forEach((file) => { if (!changedFiles.has(file)) { return; } - filteredSuccess.add(file); + filteredSuccesses.add(file); }); + if (shouldPrintSuccesses) { + if (filteredSuccesses.size === 0) { + logInfo('No successes remain after filtering by diff.'); + } else { + logInfo(`${filteredSuccesses.size} out of ${results.success.size} successes remain after filtering by diff.`); + } + } + if (filteredFailures.size === 0) { logInfo('No failures remain after filtering by diff.'); } else { - logInfo(`${filteredFailures.size} out of ${results.failures.size} files remain after filtering by diff.`); + logInfo(`${filteredFailures.size} out of ${results.failures.size} failures remain after filtering by diff.`); } return { - success: filteredSuccess, + success: filteredSuccesses, failures: filteredFailures, }; } -function printFailureSummary({success, failures}: CompilerResults): void { +function printResults({success, failures}: CompilerResults, {shouldPrintSuccesses}: PrintResultsOptions): void { // const failedFileNames = getDistinctFileNames(Array.from(failures.values()), (f) => f.file, fileToCheck); if (success.size > 0) { @@ -416,11 +429,20 @@ function printFailureSummary({success, failures}: CompilerResults): void { distinctFileNames.add(failure.file); }); + if (shouldPrintSuccesses) { + log(); + logSuccess('Successfully compiled files:'); + log(); + + success.forEach((successFile) => { + logSuccess(`${successFile}`); + }); + } + log(); logError(`Failed to compile ${distinctFileNames.size} files with React Compiler:`); log(); - // Print unique failures for the files that were checked failures.forEach((failure) => { const location = failure.line && failure.column ? `:${failure.line}:${failure.column}` : ''; logBold(`${failure.file}${location}`); @@ -512,21 +534,26 @@ async function main() { required: false, default: false, }, + printSuccesses: { + description: 'Print the successes', + required: false, + default: false, + }, }, }); const {command, file} = cli.positionalArgs; const {remote, reportFileName} = cli.namedArgs; - const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff} = cli.flags; + const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff, printSuccesses: shouldPrintSuccesses} = cli.flags; let isPassed = false; try { switch (command) { case 'check': - isPassed = Checker.check({filesToCheck: file !== '' ? [file] : undefined, shouldGenerateReport, reportFileName, shouldFilterByDiff}); + isPassed = Checker.check({filesToCheck: file !== '' ? [file] : undefined, shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}); break; case 'check-changed': - isPassed = await Checker.checkChangedFiles({remote, shouldGenerateReport, reportFileName, shouldFilterByDiff}); + isPassed = await Checker.checkChangedFiles({remote, shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}); break; default: logError(`Unknown command: ${String(command)}`); From 0e9a8534f73f7d9981f8f5a93134ced55b747096 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 12:29:13 +0100 Subject: [PATCH 20/78] fix: always print results and generate report --- scripts/react-compiler-compliance-check.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 4b5bdc328dfd..bd813ac6ed16 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -85,19 +85,14 @@ function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEF results = filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); } - const isPassed = results.failures.size === 0; - if (isPassed) { - logSuccess('All changed files pass React Compiler compliance check!'); - return true; - } - printResults(results, {shouldPrintSuccesses}); if (shouldGenerateReport) { generateReport(results, reportFileName); } - return false; + const isPassed = results.failures.size === 0; + return isPassed; } type CheckChangedFilesOptions = CommonCheckOptions & { @@ -415,11 +410,10 @@ function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: Dif } function printResults({success, failures}: CompilerResults, {shouldPrintSuccesses}: PrintResultsOptions): void { - // const failedFileNames = getDistinctFileNames(Array.from(failures.values()), (f) => f.file, fileToCheck); - - if (success.size > 0) { - log(); - logSuccess(`Successfully compiled ${success.size} files with React Compiler:`); + const isPassed = failures.size === 0; + if (isPassed) { + logSuccess('All changed files pass React Compiler compliance check!'); + return; } const tab = ' '; @@ -431,7 +425,7 @@ function printResults({success, failures}: CompilerResults, {shouldPrintSuccesse if (shouldPrintSuccesses) { log(); - logSuccess('Successfully compiled files:'); + logSuccess(`Successfully compiled ${success.size} files with React Compiler:`); log(); success.forEach((successFile) => { From 87d7a0a688354bd9c2acf098778eff72bea4f7e5 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 12:41:10 +0100 Subject: [PATCH 21/78] chore: update react-compiler-dependencies --- .eslintrc.js | 3 +- package-lock.json | 185 +++++++++++++++++++++++++--------------------- package.json | 5 +- 3 files changed, 104 insertions(+), 89 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 792bb6e89ada..9711b941c692 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -133,6 +133,7 @@ module.exports = { extends: [ 'expensify', 'airbnb-typescript', + 'plugin:react-hooks/recommended', 'plugin:storybook/recommended', 'plugin:react-native-a11y/basic', 'plugin:@dword-design/import-alias/recommended', @@ -141,7 +142,7 @@ module.exports = { 'plugin:you-dont-need-lodash-underscore/all', 'prettier', ], - plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler', 'lodash', 'deprecation'], + plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'lodash', 'deprecation'], parser: '@typescript-eslint/parser', parserOptions: { project: path.resolve(__dirname, './tsconfig.json'), diff --git a/package-lock.json b/package-lock.json index f4ea34dd2231..d7d4d3847626 100644 --- a/package-lock.json +++ b/package-lock.json @@ -229,7 +229,7 @@ "babel-jest": "29.7.0", "babel-loader": "^9.1.3", "babel-plugin-module-resolver": "^5.0.0", - "babel-plugin-react-compiler": "^19.0.0-beta-ebf51a3-20250411", + "babel-plugin-react-compiler": "^1.0.0", "babel-plugin-react-native-web": "^0.18.7", "babel-plugin-transform-remove-console": "^6.9.4", "clean-webpack-plugin": "^4.0.0", @@ -250,7 +250,7 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-jsdoc": "^46.2.6", "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-react-compiler": "^19.0.0-beta-8a03594-20241020", + "eslint-plugin-react-hooks": "^7.0.0", "eslint-plugin-react-native-a11y": "^3.3.0", "eslint-plugin-storybook": "^0.12.0", "eslint-plugin-testing-library": "^6.2.2", @@ -277,7 +277,6 @@ "portfinder": "^1.0.28", "prettier": "3.5.3", "react-compiler-healthcheck": "^19.0.0-beta-8a03594-20241020", - "react-compiler-runtime": "^19.0.0-beta-8a03594-20241020", "react-native-clean-project": "^4.0.0-alpha4.0", "react-refresh": "^0.14.2", "react-test-renderer": "19.0.0", @@ -1287,7 +1286,9 @@ } }, "node_modules/@babel/plugin-proposal-decorators": { - "version": "7.27.1", + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.28.0.tgz", + "integrity": "sha512-zOiZqvANjWDUaUS9xMxbMcK/Zccztbe/6ikvUXaG9nsPH3w6qh5UaPGAnirI/WhIbZ8m3OHU0ReyPrknG+ZKeg==", "license": "MIT", "dependencies": { "@babel/helper-create-class-features-plugin": "^7.27.1", @@ -1408,6 +1409,8 @@ }, "node_modules/@babel/plugin-syntax-decorators": { "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.27.1.tgz", + "integrity": "sha512-YMq8Z87Lhl8EGkmb0MwYkt36QnxC+fzCgrl66ereamPlYToRpIk5nUjKUY3QKLWq8mwUB1BgbeXcTJhZOCDg5A==", "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.27.1" @@ -9679,6 +9682,19 @@ } } }, + "node_modules/@react-native-community/eslint-config/node_modules/eslint-plugin-react-hooks": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", + "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + } + }, "node_modules/@react-native-community/eslint-config/node_modules/eslint-visitor-keys": { "version": "3.4.3", "dev": true, @@ -16279,8 +16295,10 @@ } }, "node_modules/babel-plugin-react-compiler": { - "version": "19.0.0-beta-ebf51a3-20250411", - "devOptional": true, + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-1.0.0.tgz", + "integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==", + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.26.0" @@ -16354,45 +16372,6 @@ "@babel/core": "^7.0.0 || ^8.0.0-0" } }, - "node_modules/babel-preset-expo": { - "version": "13.1.11", - "license": "MIT", - "dependencies": { - "@babel/helper-module-imports": "^7.25.9", - "@babel/plugin-proposal-decorators": "^7.12.9", - "@babel/plugin-proposal-export-default-from": "^7.24.7", - "@babel/plugin-syntax-export-default-from": "^7.24.7", - "@babel/plugin-transform-export-namespace-from": "^7.25.9", - "@babel/plugin-transform-flow-strip-types": "^7.25.2", - "@babel/plugin-transform-modules-commonjs": "^7.24.8", - "@babel/plugin-transform-object-rest-spread": "^7.24.7", - "@babel/plugin-transform-parameters": "^7.24.7", - "@babel/plugin-transform-private-methods": "^7.24.7", - "@babel/plugin-transform-private-property-in-object": "^7.24.7", - "@babel/plugin-transform-runtime": "^7.24.7", - "@babel/preset-react": "^7.22.15", - "@babel/preset-typescript": "^7.23.0", - "@react-native/babel-preset": "0.79.2", - "babel-plugin-react-native-web": "~0.19.13", - "babel-plugin-syntax-hermes-parser": "^0.25.1", - "babel-plugin-transform-flow-enums": "^0.0.2", - "debug": "^4.3.4", - "react-refresh": "^0.14.2", - "resolve-from": "^5.0.0" - }, - "peerDependencies": { - "babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250405" - }, - "peerDependenciesMeta": { - "babel-plugin-react-compiler": { - "optional": true - } - } - }, - "node_modules/babel-preset-expo/node_modules/babel-plugin-react-native-web": { - "version": "0.19.13", - "license": "MIT" - }, "node_modules/babel-preset-jest": { "version": "29.6.3", "license": "MIT", @@ -20355,6 +20334,19 @@ "balanced-match": "^1.0.0" } }, + "node_modules/eslint-config-expensify/node_modules/eslint-plugin-react-hooks": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", + "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + } + }, "node_modules/eslint-config-expensify/node_modules/eslint-visitor-keys": { "version": "3.4.3", "dev": true, @@ -20918,47 +20910,24 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" } }, - "node_modules/eslint-plugin-react-compiler": { - "version": "19.0.0-beta-8a03594-20241020", + "node_modules/eslint-plugin-react-hooks": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.0.0.tgz", + "integrity": "sha512-fNXaOwvKwq2+pXiRpXc825Vd63+KM4DLL40Rtlycb8m7fYpp6efrTp1sa6ZbP/Ap58K2bEKFXRmhURE+CJAQWw==", "dev": true, "license": "MIT", "dependencies": { "@babel/core": "^7.24.4", "@babel/parser": "^7.24.4", - "@babel/plugin-proposal-private-methods": "^7.18.6", - "hermes-parser": "^0.20.1", - "zod": "^3.22.4", - "zod-validation-error": "^3.0.3" + "hermes-parser": "^0.25.1", + "zod": "^3.22.4 || ^4.0.0", + "zod-validation-error": "^3.0.3 || ^4.0.0" }, "engines": { - "node": "^14.17.0 || ^16.0.0 || >= 18.0.0" - }, - "peerDependencies": { - "eslint": ">=7" - } - }, - "node_modules/eslint-plugin-react-compiler/node_modules/hermes-estree": { - "version": "0.20.1", - "dev": true, - "license": "MIT" - }, - "node_modules/eslint-plugin-react-compiler/node_modules/hermes-parser": { - "version": "0.20.1", - "dev": true, - "license": "MIT", - "dependencies": { - "hermes-estree": "0.20.1" - } - }, - "node_modules/eslint-plugin-react-hooks": { - "version": "4.6.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" + "node": ">=18" }, "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" } }, "node_modules/eslint-plugin-react-native": { @@ -21933,6 +21902,60 @@ "version": "5.0.2", "license": "MIT" }, + "node_modules/expo/node_modules/babel-plugin-react-compiler": { + "version": "19.0.0-beta-ebf51a3-20250411", + "resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-19.0.0-beta-ebf51a3-20250411.tgz", + "integrity": "sha512-q84bNR9JG1crykAlJUt5Ud0/5BUyMFuQww/mrwIQDFBaxsikqBDj3f/FNDsVd2iR26A1HvXKWPEIfgJDv8/V2g==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@babel/types": "^7.26.0" + } + }, + "node_modules/expo/node_modules/babel-plugin-react-native-web": { + "version": "0.19.13", + "resolved": "https://registry.npmjs.org/babel-plugin-react-native-web/-/babel-plugin-react-native-web-0.19.13.tgz", + "integrity": "sha512-4hHoto6xaN23LCyZgL9LJZc3olmAxd7b6jDzlZnKXAh4rRAbZRKNBJoOOdp46OBqgy+K0t0guTj5/mhA8inymQ==", + "license": "MIT" + }, + "node_modules/expo/node_modules/babel-preset-expo": { + "version": "13.1.11", + "resolved": "https://registry.npmjs.org/babel-preset-expo/-/babel-preset-expo-13.1.11.tgz", + "integrity": "sha512-jigWjvhRVdm9UTPJ1wjLYJ0OJvD5vLZ8YYkEknEl6+9S1JWORO/y3xtHr/hNj5n34nOilZqdXrmNFcqKc8YTsg==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.25.9", + "@babel/plugin-proposal-decorators": "^7.12.9", + "@babel/plugin-proposal-export-default-from": "^7.24.7", + "@babel/plugin-syntax-export-default-from": "^7.24.7", + "@babel/plugin-transform-export-namespace-from": "^7.25.9", + "@babel/plugin-transform-flow-strip-types": "^7.25.2", + "@babel/plugin-transform-modules-commonjs": "^7.24.8", + "@babel/plugin-transform-object-rest-spread": "^7.24.7", + "@babel/plugin-transform-parameters": "^7.24.7", + "@babel/plugin-transform-private-methods": "^7.24.7", + "@babel/plugin-transform-private-property-in-object": "^7.24.7", + "@babel/plugin-transform-runtime": "^7.24.7", + "@babel/preset-react": "^7.22.15", + "@babel/preset-typescript": "^7.23.0", + "@react-native/babel-preset": "0.79.2", + "babel-plugin-react-native-web": "~0.19.13", + "babel-plugin-syntax-hermes-parser": "^0.25.1", + "babel-plugin-transform-flow-enums": "^0.0.2", + "debug": "^4.3.4", + "react-refresh": "^0.14.2", + "resolve-from": "^5.0.0" + }, + "peerDependencies": { + "babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250405" + }, + "peerDependenciesMeta": { + "babel-plugin-react-compiler": { + "optional": true + } + } + }, "node_modules/expo/node_modules/brace-expansion": { "version": "2.0.1", "license": "MIT", @@ -31344,14 +31367,6 @@ "node": ">=8" } }, - "node_modules/react-compiler-runtime": { - "version": "19.0.0-beta-8a03594-20241020", - "dev": true, - "license": "MIT", - "peerDependencies": { - "react": "^18.2.0 || ^19.0.0" - } - }, "node_modules/react-content-loader": { "version": "7.0.0", "license": "MIT", diff --git a/package.json b/package.json index 1bf6022cbb5f..859bf4097020 100644 --- a/package.json +++ b/package.json @@ -299,7 +299,7 @@ "babel-jest": "29.7.0", "babel-loader": "^9.1.3", "babel-plugin-module-resolver": "^5.0.0", - "babel-plugin-react-compiler": "^19.0.0-beta-ebf51a3-20250411", + "babel-plugin-react-compiler": "^1.0.0", "babel-plugin-react-native-web": "^0.18.7", "babel-plugin-transform-remove-console": "^6.9.4", "clean-webpack-plugin": "^4.0.0", @@ -320,7 +320,7 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-jsdoc": "^46.2.6", "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-react-compiler": "^19.0.0-beta-8a03594-20241020", + "eslint-plugin-react-hooks": "^7.0.0", "eslint-plugin-react-native-a11y": "^3.3.0", "eslint-plugin-storybook": "^0.12.0", "eslint-plugin-testing-library": "^6.2.2", @@ -347,7 +347,6 @@ "portfinder": "^1.0.28", "prettier": "3.5.3", "react-compiler-healthcheck": "^19.0.0-beta-8a03594-20241020", - "react-compiler-runtime": "^19.0.0-beta-8a03594-20241020", "react-native-clean-project": "^4.0.0-alpha4.0", "react-refresh": "^0.14.2", "react-test-renderer": "19.0.0", From 2f5d5fa627b5d74e74bce928de05beff75d5674e Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 12:57:12 +0100 Subject: [PATCH 22/78] chore: make `babel-plugin-react-compiler` exact npm package version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7d4d3847626..0aac3a5239f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -229,7 +229,7 @@ "babel-jest": "29.7.0", "babel-loader": "^9.1.3", "babel-plugin-module-resolver": "^5.0.0", - "babel-plugin-react-compiler": "^1.0.0", + "babel-plugin-react-compiler": "1.0.0", "babel-plugin-react-native-web": "^0.18.7", "babel-plugin-transform-remove-console": "^6.9.4", "clean-webpack-plugin": "^4.0.0", diff --git a/package.json b/package.json index 859bf4097020..df35d38dbb94 100644 --- a/package.json +++ b/package.json @@ -299,7 +299,7 @@ "babel-jest": "29.7.0", "babel-loader": "^9.1.3", "babel-plugin-module-resolver": "^5.0.0", - "babel-plugin-react-compiler": "^1.0.0", + "babel-plugin-react-compiler": "1.0.0", "babel-plugin-react-native-web": "^0.18.7", "babel-plugin-transform-remove-console": "^6.9.4", "clean-webpack-plugin": "^4.0.0", From 6e0742be62272ce79f4807e18b4e14ff5772abfb Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:14:41 +0100 Subject: [PATCH 23/78] refactor: remove additional 'plugin:react-hooks/recommended' --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9711b941c692..c8b065b3f08b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -133,7 +133,6 @@ module.exports = { extends: [ 'expensify', 'airbnb-typescript', - 'plugin:react-hooks/recommended', 'plugin:storybook/recommended', 'plugin:react-native-a11y/basic', 'plugin:@dword-design/import-alias/recommended', From bf6ebb3205fe9f52b5e7079a0367af320e1d648c Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:16:40 +0100 Subject: [PATCH 24/78] revert: eslint-plugin-react-compiler update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df35d38dbb94..ed8f4eaf9cbd 100644 --- a/package.json +++ b/package.json @@ -320,7 +320,7 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-jsdoc": "^46.2.6", "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-react-hooks": "^7.0.0", + "eslint-plugin-react-compiler": "^19.0.0-beta-8a03594-20241020", "eslint-plugin-react-native-a11y": "^3.3.0", "eslint-plugin-storybook": "^0.12.0", "eslint-plugin-testing-library": "^6.2.2", From 7639dcdef45858b4926e507b229c4f5bd0a5d020 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:18:46 +0100 Subject: [PATCH 25/78] chore: bump eslint-plugin-react-compiler --- package-lock.json | 19 ++++++++++--------- package.json | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0aac3a5239f8..adbc1d3092a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -250,7 +250,7 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-jsdoc": "^46.2.6", "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-react-hooks": "^7.0.0", + "eslint-plugin-react-compiler": "^19.1.0-rc.2", "eslint-plugin-react-native-a11y": "^3.3.0", "eslint-plugin-storybook": "^0.12.0", "eslint-plugin-testing-library": "^6.2.2", @@ -20910,24 +20910,25 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" } }, - "node_modules/eslint-plugin-react-hooks": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.0.0.tgz", - "integrity": "sha512-fNXaOwvKwq2+pXiRpXc825Vd63+KM4DLL40Rtlycb8m7fYpp6efrTp1sa6ZbP/Ap58K2bEKFXRmhURE+CJAQWw==", + "node_modules/eslint-plugin-react-compiler": { + "version": "19.1.0-rc.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-compiler/-/eslint-plugin-react-compiler-19.1.0-rc.2.tgz", + "integrity": "sha512-oKalwDGcD+RX9mf3NEO4zOoUMeLvjSvcbbEOpquzmzqEEM2MQdp7/FY/Hx9NzmUwFzH1W9SKTz5fihfMldpEYw==", "dev": true, "license": "MIT", "dependencies": { "@babel/core": "^7.24.4", "@babel/parser": "^7.24.4", + "@babel/plugin-proposal-private-methods": "^7.18.6", "hermes-parser": "^0.25.1", - "zod": "^3.22.4 || ^4.0.0", - "zod-validation-error": "^3.0.3 || ^4.0.0" + "zod": "^3.22.4", + "zod-validation-error": "^3.0.3" }, "engines": { - "node": ">=18" + "node": "^14.17.0 || ^16.0.0 || >= 18.0.0" }, "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" + "eslint": ">=7" } }, "node_modules/eslint-plugin-react-native": { diff --git a/package.json b/package.json index ed8f4eaf9cbd..a6845a76cfb8 100644 --- a/package.json +++ b/package.json @@ -320,7 +320,7 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-jsdoc": "^46.2.6", "eslint-plugin-lodash": "^7.4.0", - "eslint-plugin-react-compiler": "^19.0.0-beta-8a03594-20241020", + "eslint-plugin-react-compiler": "^19.1.0-rc.2", "eslint-plugin-react-native-a11y": "^3.3.0", "eslint-plugin-storybook": "^0.12.0", "eslint-plugin-testing-library": "^6.2.2", From fbdb49144603cbc851aec0b295ab94707e40ff72 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:21:42 +0100 Subject: [PATCH 26/78] chore: re-enable react-compiler plugin --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index c8b065b3f08b..792bb6e89ada 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -141,7 +141,7 @@ module.exports = { 'plugin:you-dont-need-lodash-underscore/all', 'prettier', ], - plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'lodash', 'deprecation'], + plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler', 'lodash', 'deprecation'], parser: '@typescript-eslint/parser', parserOptions: { project: path.resolve(__dirname, './tsconfig.json'), From b74542ee46af35de26b61e8cc821221ec52e5a49 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:26:45 +0100 Subject: [PATCH 27/78] Update AddPlaidBankAccount.tsx --- src/components/AddPlaidBankAccount.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index a549d55671bd..4621ab014fb6 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -133,6 +133,7 @@ function AddPlaidBankAccount({ subscribedKeyboardShortcuts.current = []; }; + // dummy comment useEffect(() => { subscribeToNavigationShortcuts(); From 2678df523799ef826f64b32ef3138c7da88296e7 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:31:32 +0100 Subject: [PATCH 28/78] chore: fix package-lock.json --- package-lock.json | 248 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 222 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index f02d6e039d81..3481d4338096 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10208,19 +10208,6 @@ } } }, - "node_modules/@react-native-community/eslint-config/node_modules/eslint-plugin-react-hooks": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", - "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" - } - }, "node_modules/@react-native-community/eslint-config/node_modules/eslint-visitor-keys": { "version": "3.4.3", "dev": true, @@ -10355,6 +10342,7 @@ }, "node_modules/@react-native/babel-plugin-codegen": { "version": "0.79.2", + "dev": true, "license": "MIT", "dependencies": { "@babel/traverse": "^7.25.3", @@ -10366,6 +10354,7 @@ }, "node_modules/@react-native/babel-plugin-codegen/node_modules/@babel/traverse": { "version": "7.27.1", + "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.27.1", @@ -10382,6 +10371,7 @@ }, "node_modules/@react-native/babel-preset": { "version": "0.79.2", + "dev": true, "license": "MIT", "dependencies": { "@babel/core": "^7.25.2", @@ -20877,19 +20867,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/eslint-config-expensify/node_modules/eslint-plugin-react-hooks": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", - "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" - } - }, "node_modules/eslint-config-expensify/node_modules/eslint-visitor-keys": { "version": "3.4.3", "dev": true, @@ -21474,6 +21451,17 @@ "eslint": ">=7" } }, + "node_modules/eslint-plugin-react-hooks": { + "version": "4.6.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + } + }, "node_modules/eslint-plugin-react-native": { "version": "4.1.0", "dev": true, @@ -22438,6 +22426,24 @@ "expo": "*" } }, + "node_modules/expo/node_modules/@babel/traverse": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.4.tgz", + "integrity": "sha512-YEzuboP2qvQavAcjgQNVgsvHIDv6ZpwXvcvjmyySP2DIMuByS/6ioU5G9pYrWHM6T2YDfc7xga9iNzYOs12CFQ==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.28.3", + "@babel/helper-globals": "^7.28.0", + "@babel/parser": "^7.28.4", + "@babel/template": "^7.27.2", + "@babel/types": "^7.28.4", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/expo/node_modules/@expo/fingerprint": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/@expo/fingerprint/-/fingerprint-0.13.0.tgz", @@ -22460,6 +22466,99 @@ "fingerprint": "bin/cli.js" } }, + "node_modules/expo/node_modules/@react-native/babel-plugin-codegen": { + "version": "0.79.6", + "resolved": "https://registry.npmjs.org/@react-native/babel-plugin-codegen/-/babel-plugin-codegen-0.79.6.tgz", + "integrity": "sha512-CS5OrgcMPixOyUJ/Sk/HSsKsKgyKT5P7y3CojimOQzWqRZBmoQfxdST4ugj7n1H+ebM2IKqbgovApFbqXsoX0g==", + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.25.3", + "@react-native/codegen": "0.79.6" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/expo/node_modules/@react-native/babel-preset": { + "version": "0.79.6", + "resolved": "https://registry.npmjs.org/@react-native/babel-preset/-/babel-preset-0.79.6.tgz", + "integrity": "sha512-H+FRO+r2Ql6b5IwfE0E7D52JhkxjeGSBSUpCXAI5zQ60zSBJ54Hwh2bBJOohXWl4J+C7gKYSAd2JHMUETu+c/A==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.25.2", + "@babel/plugin-proposal-export-default-from": "^7.24.7", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-export-default-from": "^7.24.7", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-transform-arrow-functions": "^7.24.7", + "@babel/plugin-transform-async-generator-functions": "^7.25.4", + "@babel/plugin-transform-async-to-generator": "^7.24.7", + "@babel/plugin-transform-block-scoping": "^7.25.0", + "@babel/plugin-transform-class-properties": "^7.25.4", + "@babel/plugin-transform-classes": "^7.25.4", + "@babel/plugin-transform-computed-properties": "^7.24.7", + "@babel/plugin-transform-destructuring": "^7.24.8", + "@babel/plugin-transform-flow-strip-types": "^7.25.2", + "@babel/plugin-transform-for-of": "^7.24.7", + "@babel/plugin-transform-function-name": "^7.25.1", + "@babel/plugin-transform-literals": "^7.25.2", + "@babel/plugin-transform-logical-assignment-operators": "^7.24.7", + "@babel/plugin-transform-modules-commonjs": "^7.24.8", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.24.7", + "@babel/plugin-transform-nullish-coalescing-operator": "^7.24.7", + "@babel/plugin-transform-numeric-separator": "^7.24.7", + "@babel/plugin-transform-object-rest-spread": "^7.24.7", + "@babel/plugin-transform-optional-catch-binding": "^7.24.7", + "@babel/plugin-transform-optional-chaining": "^7.24.8", + "@babel/plugin-transform-parameters": "^7.24.7", + "@babel/plugin-transform-private-methods": "^7.24.7", + "@babel/plugin-transform-private-property-in-object": "^7.24.7", + "@babel/plugin-transform-react-display-name": "^7.24.7", + "@babel/plugin-transform-react-jsx": "^7.25.2", + "@babel/plugin-transform-react-jsx-self": "^7.24.7", + "@babel/plugin-transform-react-jsx-source": "^7.24.7", + "@babel/plugin-transform-regenerator": "^7.24.7", + "@babel/plugin-transform-runtime": "^7.24.7", + "@babel/plugin-transform-shorthand-properties": "^7.24.7", + "@babel/plugin-transform-spread": "^7.24.7", + "@babel/plugin-transform-sticky-regex": "^7.24.7", + "@babel/plugin-transform-typescript": "^7.25.2", + "@babel/plugin-transform-unicode-regex": "^7.24.7", + "@babel/template": "^7.25.0", + "@react-native/babel-plugin-codegen": "0.79.6", + "babel-plugin-syntax-hermes-parser": "0.25.1", + "babel-plugin-transform-flow-enums": "^0.0.2", + "react-refresh": "^0.14.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@babel/core": "*" + } + }, + "node_modules/expo/node_modules/@react-native/codegen": { + "version": "0.79.6", + "resolved": "https://registry.npmjs.org/@react-native/codegen/-/codegen-0.79.6.tgz", + "integrity": "sha512-iRBX8Lgbqypwnfba7s6opeUwVyaR23mowh9ILw7EcT2oLz3RqMmjJdrbVpWhGSMGq2qkPfqAH7bhO8C7O+xfjQ==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.25.2", + "@babel/parser": "^7.25.3", + "glob": "^7.1.1", + "hermes-parser": "0.25.1", + "invariant": "^2.2.4", + "nullthrows": "^1.1.1", + "yargs": "^17.6.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@babel/core": "*" + } + }, "node_modules/expo/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -22481,6 +22580,60 @@ "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", "license": "MIT" }, + "node_modules/expo/node_modules/babel-plugin-react-compiler": { + "version": "19.0.0-beta-ebf51a3-20250411", + "resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-19.0.0-beta-ebf51a3-20250411.tgz", + "integrity": "sha512-q84bNR9JG1crykAlJUt5Ud0/5BUyMFuQww/mrwIQDFBaxsikqBDj3f/FNDsVd2iR26A1HvXKWPEIfgJDv8/V2g==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@babel/types": "^7.26.0" + } + }, + "node_modules/expo/node_modules/babel-plugin-react-native-web": { + "version": "0.19.13", + "resolved": "https://registry.npmjs.org/babel-plugin-react-native-web/-/babel-plugin-react-native-web-0.19.13.tgz", + "integrity": "sha512-4hHoto6xaN23LCyZgL9LJZc3olmAxd7b6jDzlZnKXAh4rRAbZRKNBJoOOdp46OBqgy+K0t0guTj5/mhA8inymQ==", + "license": "MIT" + }, + "node_modules/expo/node_modules/babel-preset-expo": { + "version": "13.2.4", + "resolved": "https://registry.npmjs.org/babel-preset-expo/-/babel-preset-expo-13.2.4.tgz", + "integrity": "sha512-3IKORo3KR+4qtLdCkZNDj8KeA43oBn7RRQejFGWfiZgu/NeaRUSri8YwYjZqybm7hn3nmMv9OLahlvXBX23o5Q==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.25.9", + "@babel/plugin-proposal-decorators": "^7.12.9", + "@babel/plugin-proposal-export-default-from": "^7.24.7", + "@babel/plugin-syntax-export-default-from": "^7.24.7", + "@babel/plugin-transform-export-namespace-from": "^7.25.9", + "@babel/plugin-transform-flow-strip-types": "^7.25.2", + "@babel/plugin-transform-modules-commonjs": "^7.24.8", + "@babel/plugin-transform-object-rest-spread": "^7.24.7", + "@babel/plugin-transform-parameters": "^7.24.7", + "@babel/plugin-transform-private-methods": "^7.24.7", + "@babel/plugin-transform-private-property-in-object": "^7.24.7", + "@babel/plugin-transform-runtime": "^7.24.7", + "@babel/preset-react": "^7.22.15", + "@babel/preset-typescript": "^7.23.0", + "@react-native/babel-preset": "0.79.6", + "babel-plugin-react-native-web": "~0.19.13", + "babel-plugin-syntax-hermes-parser": "^0.25.1", + "babel-plugin-transform-flow-enums": "^0.0.2", + "debug": "^4.3.4", + "react-refresh": "^0.14.2", + "resolve-from": "^5.0.0" + }, + "peerDependencies": { + "babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250405" + }, + "peerDependenciesMeta": { + "babel-plugin-react-compiler": { + "optional": true + } + } + }, "node_modules/expo/node_modules/brace-expansion": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", @@ -22533,6 +22686,49 @@ "node": ">=6" } }, + "node_modules/expo/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/expo/node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/expo/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/expo/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", From 08d51ad2d942bf363137f1117d30aade21c6d90a Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:31:39 +0100 Subject: [PATCH 29/78] remove dummy comment --- src/components/AddPlaidBankAccount.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index 4621ab014fb6..a549d55671bd 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -133,7 +133,6 @@ function AddPlaidBankAccount({ subscribedKeyboardShortcuts.current = []; }; - // dummy comment useEffect(() => { subscribeToNavigationShortcuts(); From 63ba0d02c73e50d27b6d8c4591664d6677f226c4 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:37:56 +0100 Subject: [PATCH 30/78] docs: add REACT_COMPILER.md section for new flags --- contributingGuides/REACT_COMPILER.md | 38 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/contributingGuides/REACT_COMPILER.md b/contributingGuides/REACT_COMPILER.md index 5901a35ff7be..997b07d04dae 100644 --- a/contributingGuides/REACT_COMPILER.md +++ b/contributingGuides/REACT_COMPILER.md @@ -32,7 +32,7 @@ npm run react-compiler-compliance-check check src/path/Component.tsx # Check spe npm run react-compiler-compliance-check check "src/**/*.tsx" # Check glob pattern ``` -#### Check only changed files against a remote main (default remote is `origin`) +#### Check only changed files (against main) ```bash npm run react-compiler-compliance-check check-changed @@ -47,12 +47,42 @@ npm run react-compiler-compliance-check check --report npm run react-compiler-compliance-check check-changed --report ``` -## How can I check what exactly prevents file from successful optimization or whether my fix for passing `react-compiler` actually works? +#### Additional flags -You can run a dedicated script: `react-compiler-healthcheck-test` and examine the output. This command will list the files that failed to compile with details on what caused the failures. It will then save this output to `./react-compiler-output.txt` file. Read and examine the output to find what specific error the react-compiler throws. +**Filter by diff changes (`--filterByDiff`)** + +Only check files that have been modified in the current diff. This is useful when you want to focus on files that have actual changes: + +```bash +npm run react-compiler-compliance-check check --filterByDiff +npm run react-compiler-compliance-check check-changed --filterByDiff +``` + +**Print successful compilations (`--printSuccesses`)** + +By default, the script only shows compilation failures. Use this flag to also display files that compiled successfully: + +```bash +npm run react-compiler-compliance-check check --printSuccesses +npm run react-compiler-compliance-check check-changed --printSuccesses +``` + +**Custom report filename (`--reportFileName`)** + +Specify a custom filename for the generated report instead of the default `react-compiler-report.json`: + +```bash +npm run react-compiler-compliance-check check --report --reportFileName my-custom-report.json +npm run react-compiler-compliance-check check-changed --report --reportFileName my-custom-report.json +``` + +**Custom remote name (`--remote`)** + +By default, the script uses `origin` as the base remote. If your GitHub remote is named differently, specify it with this flag: ```bash -npm run react-compiler-healthcheck-test +npm run react-compiler-compliance-check check-changed --remote upstream +npm run react-compiler-compliance-check check --filterByDiff --remote my-remote ``` ## How to fix a particular problem? From 7f9f4cf8d5b96e8366b31b529d0102dc35721d78 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:42:59 +0100 Subject: [PATCH 31/78] chore: run `npm run gh-actions-build` --- .../getPullRequestIncrementalChanges/index.js | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js index 48bdf304a75c..abd621a5c4b2 100644 --- a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js +++ b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js @@ -12536,7 +12536,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.GIT_ERRORS = void 0; const github_1 = __nccwpck_require__(5438); const child_process_1 = __nccwpck_require__(2081); const util_1 = __nccwpck_require__(3837); @@ -12544,10 +12543,6 @@ const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); const Logger_1 = __nccwpck_require__(8891); const exec = (0, util_1.promisify)(child_process_1.exec); const IS_CI = process.env.CI === 'true'; -const GIT_ERRORS = { - FAILED_TO_FETCH_FROM_REMOTE: 'Failed to fetch from remote', -}; -exports.GIT_ERRORS = GIT_ERRORS; /** * Utility class for git operations. */ @@ -12790,19 +12785,17 @@ class Git { throw new Error(`Failed to fetch git reference ${ref}: ${error instanceof Error ? error.message : String(error)}`); } } - static getMainBaseCommitHash(remote) { - // Fetch the main branch from the specified remote to ensure it's available - try { - (0, child_process_1.execSync)(`git fetch ${remote} main --no-tags --depth=1 -q`, { encoding: 'utf8' }); - } - catch (error) { - throw new Error(GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE); + static getMainBranchCommitHash(remote) { + // Fetch the main branch from the specified remote (or locally) to ensure it's available + if (IS_CI || remote) { + this.ensureRef('main', remote); } // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { + const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; try { - const mergeBaseHash = (0, child_process_1.execSync)(`git rev-parse ${remote}/main`, { encoding: 'utf8' }).trim(); + const mergeBaseHash = (0, child_process_1.execSync)(`git rev-parse ${mainBaseRef}`, { encoding: 'utf8' }).trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { throw new Error(`git rev-parse returned unexpected output: ${mergeBaseHash}`); @@ -12810,25 +12803,25 @@ class Git { return mergeBaseHash; } catch (error) { - (0, Logger_1.error)(`Failed to get commit hash for ${remote}/main:`, error); - throw new Error(`Could not get commit hash for ${remote}/main`); + (0, Logger_1.error)(`Failed to get commit hash for ${mainBaseRef}:`, error); + throw new Error(`Could not get commit hash for ${mainBaseRef}`); } } + const mainBaseRef = remote ? `${remote}/main` : 'main'; // For local development, try to find the actual merge base let mergeBaseHash; try { - mergeBaseHash = (0, child_process_1.execSync)(`git merge-base ${remote}/main HEAD`, { encoding: 'utf8' }).trim(); + mergeBaseHash = (0, child_process_1.execSync)(`git merge-base ${mainBaseRef} HEAD`, { encoding: 'utf8' }).trim(); } - catch (error) { + catch { + (0, Logger_1.warn)(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - mergeBaseHash = (0, child_process_1.execSync)(`git rev-parse ${remote}/main`, { encoding: 'utf8' }).trim(); - (0, Logger_1.error)(`Warning: Could not find merge base between ${remote}/main and HEAD. Using ${remote}/main as base.`); + mergeBaseHash = (0, child_process_1.execSync)(`git rev-parse ${mainBaseRef}`, { encoding: 'utf8' }).trim(); } catch (fallbackError) { - (0, Logger_1.error)(`Failed to find merge base with ${remote}/main:`, error); - (0, Logger_1.error)(`Fallback also failed:`, fallbackError); - throw new Error(`Could not determine merge base with ${remote}/main`); + (0, Logger_1.error)(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); + throw new Error(`Could not determine merge base with ${mainBaseRef}`); } } // Validate the output is a proper SHA hash @@ -12837,7 +12830,24 @@ class Git { } return mergeBaseHash; } - static async getChangedFiles(remote) { + /** + * Check if there are any uncommitted changes (both staged and unstaged). + * + * @returns true if there are uncommitted changes, false otherwise + */ + static hasUncommittedChanges() { + try { + const status = (0, child_process_1.execSync)('git status --porcelain', { + encoding: 'utf8', + cwd: process.cwd(), + }).trim(); + return status.length > 0; + } + catch (error) { + return false; + } + } + static async getChangedFiles(fromRef, toRef = 'HEAD') { if (IS_CI) { const { data: changedFiles } = await GithubUtils_1.default.octokit.pulls.listFiles({ owner: 'Expensify', @@ -12848,19 +12858,12 @@ class Git { return changedFiles.map((file) => file.filename); } try { - // Get files changed in the current branch/commit - const mainBaseCommitHash = this.getMainBaseCommitHash(remote); // Get the diff output and check status - const gitDiffOutput = (0, child_process_1.execSync)(`git diff --diff-filter=AMR --name-only ${mainBaseCommitHash} HEAD`, { - encoding: 'utf8', - }); - const files = gitDiffOutput.trim().split('\n'); + const diffResult = this.diff(fromRef, toRef); + const files = diffResult.files.map((file) => file.filePath); return files; } catch (error) { - if (error instanceof Error && error.message === GIT_ERRORS.FAILED_TO_FETCH_FROM_REMOTE) { - throw error; - } (0, Logger_1.error)('Could not determine changed files:', error); throw error; } From 7c673e94966ce81b9484c0df8ab7f32deef12f48 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:44:15 +0100 Subject: [PATCH 32/78] chore: add duplicated compliance check for testing --- .../react-compiler-compliance-v2.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/react-compiler-compliance-v2.yml diff --git a/.github/workflows/react-compiler-compliance-v2.yml b/.github/workflows/react-compiler-compliance-v2.yml new file mode 100644 index 000000000000..88bdeba70ded --- /dev/null +++ b/.github/workflows/react-compiler-compliance-v2.yml @@ -0,0 +1,31 @@ +name: React Compiler Compliance Check v2 + +on: + workflow_call: + pull_request: + types: [opened, synchronize] + branches-ignore: [staging, production] + paths: ["**.tsx"] + +concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-react-compiler-compliance + cancel-in-progress: true +jobs: + react-compiler-compliance: + name: React Compiler Compliance + if: ${{ github.actor != 'OSBotify' }} + runs-on: ubuntu-latest + + steps: + # v4 + - name: Checkout + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Run React Compiler Compliance Check + run: npm run react-compiler-compliance-check check-changed --filterByDiff + env: + CI: true + GITHUB_TOKEN: ${{ github.token }} From 933537cb91d6ff63060c6891eff03ef7c6f834e2 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 13:57:09 +0100 Subject: [PATCH 33/78] refactor: simplify CLI options forwarding --- scripts/react-compiler-compliance-check.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index bd813ac6ed16..4f96677c1936 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -540,14 +540,16 @@ async function main() { const {remote, reportFileName} = cli.namedArgs; const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff, printSuccesses: shouldPrintSuccesses} = cli.flags; + const commonOptions: CommonCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; + let isPassed = false; try { switch (command) { case 'check': - isPassed = Checker.check({filesToCheck: file !== '' ? [file] : undefined, shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}); + isPassed = Checker.check({filesToCheck: file !== '' ? [file] : undefined, ...commonOptions}); break; case 'check-changed': - isPassed = await Checker.checkChangedFiles({remote, shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}); + isPassed = await Checker.checkChangedFiles({remote, ...commonOptions}); break; default: logError(`Unknown command: ${String(command)}`); From 5c8d468ac82a5c99edca08e9abe6d48a7e62aea0 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 14:06:46 +0100 Subject: [PATCH 34/78] refactor: run `git fetch` quitly --- scripts/utils/Git.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 0be93c4dbffb..f319053e0719 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -298,7 +298,7 @@ class Git { try { console.log(`🔄 Fetching missing ref: ${ref}`); - await exec(`git fetch --no-tags --depth=1 ${remote} ${ref}`, { + await exec(`git fetch --no-tags --depth=1 --quiet ${remote} ${ref}`, { encoding: 'utf8', cwd: process.cwd(), }); From 935498fd90f6ad321292482d8586c69d7db80028 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 14:06:50 +0100 Subject: [PATCH 35/78] add log --- scripts/utils/Git.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index f319053e0719..374f64980584 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -292,6 +292,7 @@ class Git { * @throws Error when the reference cannot be fetched or is invalid */ static async ensureRef(ref: string, remote = 'origin'): Promise { + console.log('isValidRef', this.isValidRef(ref)); if (this.isValidRef(ref)) { return; // Reference is already available locally } From 1393b3cae00b29a1160d714b0a5371f7bac25ad5 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 14:14:14 +0100 Subject: [PATCH 36/78] add log --- scripts/utils/Git.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 374f64980584..ab6df9c33032 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -319,6 +319,8 @@ class Git { this.ensureRef('main', remote); } + console.log(IS_CI, remote); + // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { From 6466a7b89c8b9804c68d648dcf5852b7fbcccf22 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 14:21:55 +0100 Subject: [PATCH 37/78] fix: rev-parse not waiting for git fetch --- scripts/utils/Git.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index ab6df9c33032..2b7fb1019192 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -2,7 +2,7 @@ import {context} from '@actions/github'; import {execSync, exec as execWithCallback} from 'child_process'; import {promisify} from 'util'; import GitHubUtils from '@github/libs/GithubUtils'; -import {error as logError, warn as logWarn} from './Logger'; +import {log, error as logError, warn as logWarn} from './Logger'; const exec = promisify(execWithCallback); @@ -292,13 +292,12 @@ class Git { * @throws Error when the reference cannot be fetched or is invalid */ static async ensureRef(ref: string, remote = 'origin'): Promise { - console.log('isValidRef', this.isValidRef(ref)); if (this.isValidRef(ref)) { return; // Reference is already available locally } try { - console.log(`🔄 Fetching missing ref: ${ref}`); + log(`🔄 Fetching missing ref: ${ref}`); await exec(`git fetch --no-tags --depth=1 --quiet ${remote} ${ref}`, { encoding: 'utf8', cwd: process.cwd(), @@ -313,14 +312,12 @@ class Git { } } - static getMainBranchCommitHash(remote?: string): string { + static async getMainBranchCommitHash(remote?: string): Promise { // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { - this.ensureRef('main', remote); + await this.ensureRef('main', remote); } - console.log(IS_CI, remote); - // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { From 09306d1ac88ee5a32a6350b94560541ba8c64288 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 14:23:59 +0100 Subject: [PATCH 38/78] fix: await Git. getMainBranchCommitHash --- scripts/react-compiler-compliance-check.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 4f96677c1936..68896106520f 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -103,7 +103,7 @@ async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOpti logInfo('Checking changed files for React Compiler compliance...'); try { - const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); + const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); const changedFiles = await Git.getChangedFiles(mainBaseCommitHash); const filesToCheck = [...new Set(changedFiles)]; From ea15849077cd7ba0fad2e44b385ed049011d39c2 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 14:33:22 +0100 Subject: [PATCH 39/78] refactor: make Git functions async --- scripts/react-compiler-compliance-check.ts | 21 ++++++++++++------ scripts/utils/Git.ts | 25 ++++++++++++++++------ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 68896106520f..63c1e3630d58 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -68,7 +68,14 @@ type CheckOptions = CommonCheckOptions & { filesToCheck?: string[]; }; -function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote, shouldPrintSuccesses = false}: CheckOptions) { +async function check({ + filesToCheck, + shouldGenerateReport = false, + reportFileName = DEFAULT_REPORT_FILENAME, + shouldFilterByDiff = false, + remote, + shouldPrintSuccesses = false, +}: CheckOptions): Promise { if (filesToCheck) { logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); } else { @@ -79,10 +86,10 @@ function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEF let results = runCompilerHealthcheck(src); if (shouldFilterByDiff) { - const mainBaseCommitHash = Git.getMainBranchCommitHash(remote); + const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); const headCommitHash = 'HEAD'; const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; - results = filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); + results = await filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); } printResults(results, {shouldPrintSuccesses}); @@ -112,7 +119,7 @@ async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOpti return true; } - return check({filesToCheck, ...restOptions}); + return await check({filesToCheck, ...restOptions}); } catch { return false; } @@ -328,9 +335,9 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * @param diffFilteringCommits - The commit range to diff (from and to) * @returns Filtered compiler results containing only failures in changed lines */ -function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): CompilerResults { +async function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): Promise { // Check for uncommitted changes and warn if any exist - if (Git.hasUncommittedChanges()) { + if (await Git.hasUncommittedChanges()) { logWarn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); } @@ -546,7 +553,7 @@ async function main() { try { switch (command) { case 'check': - isPassed = Checker.check({filesToCheck: file !== '' ? [file] : undefined, ...commonOptions}); + isPassed = await Checker.check({filesToCheck: file !== '' ? [file] : undefined, ...commonOptions}); break; case 'check-changed': isPassed = await Checker.checkChangedFiles({remote, ...commonOptions}); diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 2b7fb1019192..d9636573554c 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -324,7 +324,11 @@ class Git { const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; try { - const mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); + const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + const mergeBaseHash = revParseOutput.trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { @@ -343,13 +347,21 @@ class Git { // For local development, try to find the actual merge base let mergeBaseHash: string; try { - mergeBaseHash = execSync(`git merge-base ${mainBaseRef} HEAD`, {encoding: 'utf8'}).trim(); + const {stdout: mergeBaseOutput} = await exec(`git merge-base ${mainBaseRef} HEAD`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + mergeBaseHash = mergeBaseOutput.trim(); } catch { logWarn(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); + const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + mergeBaseHash = revParseOutput.trim(); } catch (fallbackError) { logError(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); throw new Error(`Could not determine merge base with ${mainBaseRef}`); @@ -369,12 +381,13 @@ class Git { * * @returns true if there are uncommitted changes, false otherwise */ - static hasUncommittedChanges(): boolean { + static async hasUncommittedChanges(): Promise { try { - const status = execSync('git status --porcelain', { + const {stdout} = await exec('git status --porcelain', { encoding: 'utf8', cwd: process.cwd(), - }).trim(); + }); + const status = stdout.trim(); return status.length > 0; } catch (error) { return false; From ab9f072ce5b7649f750c0e82ab38d77c6479d640 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 15:00:07 +0100 Subject: [PATCH 40/78] chore: run `npm run gh-actions-build` --- .../getPullRequestIncrementalChanges/index.js | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js index abd621a5c4b2..a1032bc6f641 100644 --- a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js +++ b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js @@ -12771,8 +12771,8 @@ class Git { return; // Reference is already available locally } try { - console.log(`🔄 Fetching missing ref: ${ref}`); - await exec(`git fetch --no-tags --depth=1 ${remote} ${ref}`, { + (0, Logger_1.log)(`🔄 Fetching missing ref: ${ref}`); + await exec(`git fetch --no-tags --depth=1 --quiet ${remote} ${ref}`, { encoding: 'utf8', cwd: process.cwd(), }); @@ -12785,17 +12785,21 @@ class Git { throw new Error(`Failed to fetch git reference ${ref}: ${error instanceof Error ? error.message : String(error)}`); } } - static getMainBranchCommitHash(remote) { + static async getMainBranchCommitHash(remote) { // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { - this.ensureRef('main', remote); + await this.ensureRef('main', remote); } // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; try { - const mergeBaseHash = (0, child_process_1.execSync)(`git rev-parse ${mainBaseRef}`, { encoding: 'utf8' }).trim(); + const { stdout: revParseOutput } = await exec(`git rev-parse ${mainBaseRef}`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + const mergeBaseHash = revParseOutput.trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { throw new Error(`git rev-parse returned unexpected output: ${mergeBaseHash}`); @@ -12811,13 +12815,21 @@ class Git { // For local development, try to find the actual merge base let mergeBaseHash; try { - mergeBaseHash = (0, child_process_1.execSync)(`git merge-base ${mainBaseRef} HEAD`, { encoding: 'utf8' }).trim(); + const { stdout: mergeBaseOutput } = await exec(`git merge-base ${mainBaseRef} HEAD`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + mergeBaseHash = mergeBaseOutput.trim(); } catch { (0, Logger_1.warn)(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - mergeBaseHash = (0, child_process_1.execSync)(`git rev-parse ${mainBaseRef}`, { encoding: 'utf8' }).trim(); + const { stdout: revParseOutput } = await exec(`git rev-parse ${mainBaseRef}`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + mergeBaseHash = revParseOutput.trim(); } catch (fallbackError) { (0, Logger_1.error)(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); @@ -12835,12 +12847,13 @@ class Git { * * @returns true if there are uncommitted changes, false otherwise */ - static hasUncommittedChanges() { + static async hasUncommittedChanges() { try { - const status = (0, child_process_1.execSync)('git status --porcelain', { + const { stdout } = await exec('git status --porcelain', { encoding: 'utf8', cwd: process.cwd(), - }).trim(); + }); + const status = stdout.trim(); return status.length > 0; } catch (error) { From ab0a5b774f2ffbce9e833059eb11b5db65e3eb87 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 16:14:15 +0100 Subject: [PATCH 41/78] fix: promise + switch case refactoring --- scripts/react-compiler-compliance-check.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 63c1e3630d58..4da584fcb867 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -550,18 +550,21 @@ async function main() { const commonOptions: CommonCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; let isPassed = false; - try { + + async function runCommand() { switch (command) { case 'check': - isPassed = await Checker.check({filesToCheck: file !== '' ? [file] : undefined, ...commonOptions}); - break; + return Checker.check({filesToCheck: file !== '' ? [file] : undefined, ...commonOptions}); case 'check-changed': - isPassed = await Checker.checkChangedFiles({remote, ...commonOptions}); - break; + return Checker.checkChangedFiles({remote, ...commonOptions}); default: logError(`Unknown command: ${String(command)}`); - isPassed = false; + return Promise.resolve(false); } + } + + try { + isPassed = await runCommand(); } catch (error) { isPassed = false; } finally { From 7f3b7a64c1c2bea30c05d6adcec19576a85f5589 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 16:49:29 +0100 Subject: [PATCH 42/78] refactor: rename git function --- scripts/react-compiler-compliance-check.ts | 2 +- scripts/utils/Git.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 4da584fcb867..54c1f9fd3891 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -111,7 +111,7 @@ async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOpti try { const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); - const changedFiles = await Git.getChangedFiles(mainBaseCommitHash); + const changedFiles = await Git.getChangedFileNames(mainBaseCommitHash); const filesToCheck = [...new Set(changedFiles)]; if (filesToCheck.length === 0) { diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index d9636573554c..c2fa5bb89510 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -394,7 +394,7 @@ class Git { } } - static async getChangedFiles(fromRef: string, toRef = 'HEAD'): Promise { + static async getChangedFileNames(fromRef: string, toRef = 'HEAD'): Promise { if (IS_CI) { const {data: changedFiles} = await GitHubUtils.octokit.pulls.listFiles({ owner: 'Expensify', From 8d35341a8fc3b576cf2db0b3beaa8e0143251eef Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 16:49:43 +0100 Subject: [PATCH 43/78] refactor: extract GITHUB_CONSTANTS --- scripts/GITHUB_CONSTANTS.ts | 6 ++++++ scripts/aggregateGitHubDataFromUpwork.ts | 7 ++++--- scripts/utils/Git.ts | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 scripts/GITHUB_CONSTANTS.ts diff --git a/scripts/GITHUB_CONSTANTS.ts b/scripts/GITHUB_CONSTANTS.ts new file mode 100644 index 000000000000..c4215ac01205 --- /dev/null +++ b/scripts/GITHUB_CONSTANTS.ts @@ -0,0 +1,6 @@ +const GITHUB_CONSTANTS = { + GITHUB_OWNER: 'Expensify', + GITHUB_REPO: 'App', +}; + +export default GITHUB_CONSTANTS; diff --git a/scripts/aggregateGitHubDataFromUpwork.ts b/scripts/aggregateGitHubDataFromUpwork.ts index f47b2b43e5cc..45cbc6d3fc0d 100644 --- a/scripts/aggregateGitHubDataFromUpwork.ts +++ b/scripts/aggregateGitHubDataFromUpwork.ts @@ -12,6 +12,7 @@ import {paginateRest} from '@octokit/plugin-paginate-rest'; import {throttling} from '@octokit/plugin-throttling'; import {createObjectCsvWriter} from 'csv-writer'; import fs from 'fs'; +import GITHUB_CONSTANTS from './GITHUB_CONSTANTS'; type OctokitOptions = {method: string; url: string; request: {retryCount: number}}; type IssueType = 'bug' | 'feature' | 'other'; @@ -112,7 +113,7 @@ async function getProjectsForIssue(issueNumber: number): Promise { const response = await octokit.graphql( ` { - repository(owner: "Expensify", name: "App") { + repository(owner: "${GITHUB_CONSTANTS.GITHUB_OWNER}", name: "${GITHUB_CONSTANTS.GITHUB_REPO}") { issue(number: ${issueNumber}) { projectsV2(last: 30) { nodes { @@ -134,8 +135,8 @@ async function getGitHubData() { console.info(`Fetching ${issueNumber}`); const result = await octokit.rest.issues .get({ - owner: 'Expensify', - repo: 'App', + owner: GITHUB_CONSTANTS.GITHUB_OWNER, + repo: GITHUB_CONSTANTS.GITHUB_REPO, // eslint-disable-next-line @typescript-eslint/naming-convention issue_number: issueNumber, }) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index c2fa5bb89510..57a63604e210 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -2,6 +2,7 @@ import {context} from '@actions/github'; import {execSync, exec as execWithCallback} from 'child_process'; import {promisify} from 'util'; import GitHubUtils from '@github/libs/GithubUtils'; +import GITHUB_CONSTANTS from '@scripts/GITHUB_CONSTANTS'; import {log, error as logError, warn as logWarn} from './Logger'; const exec = promisify(execWithCallback); @@ -397,8 +398,8 @@ class Git { static async getChangedFileNames(fromRef: string, toRef = 'HEAD'): Promise { if (IS_CI) { const {data: changedFiles} = await GitHubUtils.octokit.pulls.listFiles({ - owner: 'Expensify', - repo: 'App', + owner: GITHUB_CONSTANTS.GITHUB_OWNER, + repo: GITHUB_CONSTANTS.GITHUB_REPO, // eslint-disable-next-line @typescript-eslint/naming-convention pull_number: context.payload.pull_request?.number ?? 0, }); From fd4e5cf2233a55a471b65cecd2d75507002410f2 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 16:52:15 +0100 Subject: [PATCH 44/78] revert: async changes --- scripts/react-compiler-compliance-check.ts | 29 ++++++++-------------- scripts/utils/Git.ts | 25 +++++-------------- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 54c1f9fd3891..c0a4cb31f19c 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -52,30 +52,22 @@ type DiffFilteringCommits = { to: string; }; +type PrintResultsOptions = { + shouldPrintSuccesses: boolean; +}; + type CommonCheckOptions = { remote?: string; shouldGenerateReport?: boolean; reportFileName?: string; shouldFilterByDiff?: boolean; - shouldPrintSuccesses?: boolean; -}; - -type PrintResultsOptions = { - shouldPrintSuccesses: boolean; -}; +} & PrintResultsOptions; type CheckOptions = CommonCheckOptions & { filesToCheck?: string[]; }; -async function check({ - filesToCheck, - shouldGenerateReport = false, - reportFileName = DEFAULT_REPORT_FILENAME, - shouldFilterByDiff = false, - remote, - shouldPrintSuccesses = false, -}: CheckOptions): Promise { +async function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote, shouldPrintSuccesses = false}: CheckOptions) { if (filesToCheck) { logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); } else { @@ -89,7 +81,7 @@ async function check({ const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); const headCommitHash = 'HEAD'; const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; - results = await filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); + results = filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); } printResults(results, {shouldPrintSuccesses}); @@ -335,9 +327,9 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * @param diffFilteringCommits - The commit range to diff (from and to) * @returns Filtered compiler results containing only failures in changed lines */ -async function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): Promise { +function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): CompilerResults { // Check for uncommitted changes and warn if any exist - if (await Git.hasUncommittedChanges()) { + if (Git.hasUncommittedChanges()) { logWarn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); } @@ -549,8 +541,6 @@ async function main() { const commonOptions: CommonCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; - let isPassed = false; - async function runCommand() { switch (command) { case 'check': @@ -563,6 +553,7 @@ async function main() { } } + let isPassed = false; try { isPassed = await runCommand(); } catch (error) { diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 57a63604e210..31e6d39965e0 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -325,11 +325,7 @@ class Git { const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; try { - const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); - const mergeBaseHash = revParseOutput.trim(); + const mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { @@ -348,21 +344,13 @@ class Git { // For local development, try to find the actual merge base let mergeBaseHash: string; try { - const {stdout: mergeBaseOutput} = await exec(`git merge-base ${mainBaseRef} HEAD`, { - encoding: 'utf8', - cwd: process.cwd(), - }); - mergeBaseHash = mergeBaseOutput.trim(); + mergeBaseHash = execSync(`git merge-base ${mainBaseRef} HEAD`, {encoding: 'utf8'}).trim(); } catch { logWarn(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); - mergeBaseHash = revParseOutput.trim(); + mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); } catch (fallbackError) { logError(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); throw new Error(`Could not determine merge base with ${mainBaseRef}`); @@ -382,13 +370,12 @@ class Git { * * @returns true if there are uncommitted changes, false otherwise */ - static async hasUncommittedChanges(): Promise { + static hasUncommittedChanges(): boolean { try { - const {stdout} = await exec('git status --porcelain', { + const status = execSync('git status --porcelain', { encoding: 'utf8', cwd: process.cwd(), - }); - const status = stdout.trim(); + }).trim(); return status.length > 0; } catch (error) { return false; From 6293b0140350ec6662b1843b4191de4b003542b2 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 16:54:39 +0100 Subject: [PATCH 45/78] Revert "revert: async changes" This reverts commit fd4e5cf2233a55a471b65cecd2d75507002410f2. --- scripts/react-compiler-compliance-check.ts | 29 ++++++++++++++-------- scripts/utils/Git.ts | 25 ++++++++++++++----- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index c0a4cb31f19c..54c1f9fd3891 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -52,22 +52,30 @@ type DiffFilteringCommits = { to: string; }; -type PrintResultsOptions = { - shouldPrintSuccesses: boolean; -}; - type CommonCheckOptions = { remote?: string; shouldGenerateReport?: boolean; reportFileName?: string; shouldFilterByDiff?: boolean; -} & PrintResultsOptions; + shouldPrintSuccesses?: boolean; +}; + +type PrintResultsOptions = { + shouldPrintSuccesses: boolean; +}; type CheckOptions = CommonCheckOptions & { filesToCheck?: string[]; }; -async function check({filesToCheck, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, remote, shouldPrintSuccesses = false}: CheckOptions) { +async function check({ + filesToCheck, + shouldGenerateReport = false, + reportFileName = DEFAULT_REPORT_FILENAME, + shouldFilterByDiff = false, + remote, + shouldPrintSuccesses = false, +}: CheckOptions): Promise { if (filesToCheck) { logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); } else { @@ -81,7 +89,7 @@ async function check({filesToCheck, shouldGenerateReport = false, reportFileName const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); const headCommitHash = 'HEAD'; const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; - results = filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); + results = await filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); } printResults(results, {shouldPrintSuccesses}); @@ -327,9 +335,9 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * @param diffFilteringCommits - The commit range to diff (from and to) * @returns Filtered compiler results containing only failures in changed lines */ -function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): CompilerResults { +async function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): Promise { // Check for uncommitted changes and warn if any exist - if (Git.hasUncommittedChanges()) { + if (await Git.hasUncommittedChanges()) { logWarn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); } @@ -541,6 +549,8 @@ async function main() { const commonOptions: CommonCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; + let isPassed = false; + async function runCommand() { switch (command) { case 'check': @@ -553,7 +563,6 @@ async function main() { } } - let isPassed = false; try { isPassed = await runCommand(); } catch (error) { diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 31e6d39965e0..57a63604e210 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -325,7 +325,11 @@ class Git { const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; try { - const mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); + const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + const mergeBaseHash = revParseOutput.trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { @@ -344,13 +348,21 @@ class Git { // For local development, try to find the actual merge base let mergeBaseHash: string; try { - mergeBaseHash = execSync(`git merge-base ${mainBaseRef} HEAD`, {encoding: 'utf8'}).trim(); + const {stdout: mergeBaseOutput} = await exec(`git merge-base ${mainBaseRef} HEAD`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + mergeBaseHash = mergeBaseOutput.trim(); } catch { logWarn(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - mergeBaseHash = execSync(`git rev-parse ${mainBaseRef}`, {encoding: 'utf8'}).trim(); + const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { + encoding: 'utf8', + cwd: process.cwd(), + }); + mergeBaseHash = revParseOutput.trim(); } catch (fallbackError) { logError(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); throw new Error(`Could not determine merge base with ${mainBaseRef}`); @@ -370,12 +382,13 @@ class Git { * * @returns true if there are uncommitted changes, false otherwise */ - static hasUncommittedChanges(): boolean { + static async hasUncommittedChanges(): Promise { try { - const status = execSync('git status --porcelain', { + const {stdout} = await exec('git status --porcelain', { encoding: 'utf8', cwd: process.cwd(), - }).trim(); + }); + const status = stdout.trim(); return status.length > 0; } catch (error) { return false; From ca5aafb9dd3211753ee71293b9be6030525e67b5 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:02:31 +0100 Subject: [PATCH 46/78] refactor: restructure types and add back error logging --- scripts/react-compiler-compliance-check.ts | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 54c1f9fd3891..0f29342be198 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -52,16 +52,15 @@ type DiffFilteringCommits = { to: string; }; -type CommonCheckOptions = { +type PrintResultsOptions = { + shouldPrintSuccesses: boolean; +}; + +type CommonCheckOptions = PrintResultsOptions & { remote?: string; - shouldGenerateReport?: boolean; reportFileName?: string; + shouldGenerateReport?: boolean; shouldFilterByDiff?: boolean; - shouldPrintSuccesses?: boolean; -}; - -type PrintResultsOptions = { - shouldPrintSuccesses: boolean; }; type CheckOptions = CommonCheckOptions & { @@ -102,9 +101,7 @@ async function check({ return isPassed; } -type CheckChangedFilesOptions = CommonCheckOptions & { - reportFileName?: string; -}; +type CheckChangedFilesOptions = CommonCheckOptions; async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOptions): Promise { logInfo('Checking changed files for React Compiler compliance...'); @@ -120,7 +117,8 @@ async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOpti } return await check({filesToCheck, ...restOptions}); - } catch { + } catch (error) { + logError('Error checking changed files for React Compiler compliance:', error); return false; } } @@ -549,8 +547,6 @@ async function main() { const commonOptions: CommonCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; - let isPassed = false; - async function runCommand() { switch (command) { case 'check': @@ -563,9 +559,11 @@ async function main() { } } + let isPassed = false; try { isPassed = await runCommand(); } catch (error) { + logError('Error running react-compiler-compliance-check:', error); isPassed = false; } finally { process.exit(isPassed ? 0 : 1); From 1220b6ae86acb79a4adcaf8c0f1d1294cbfe7141 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:16:36 +0100 Subject: [PATCH 47/78] refactor: improve errors --- scripts/react-compiler-compliance-check.ts | 21 ++++++++------------- scripts/utils/Git.ts | 15 +++++---------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 0f29342be198..b093a0ce28ac 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -106,21 +106,16 @@ type CheckChangedFilesOptions = CommonCheckOptions; async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOptions): Promise { logInfo('Checking changed files for React Compiler compliance...'); - try { - const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); - const changedFiles = await Git.getChangedFileNames(mainBaseCommitHash); - const filesToCheck = [...new Set(changedFiles)]; - - if (filesToCheck.length === 0) { - logSuccess('No React files changed, skipping check.'); - return true; - } + const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); + const changedFiles = await Git.getChangedFileNames(mainBaseCommitHash); + const filesToCheck = [...new Set(changedFiles)]; - return await check({filesToCheck, ...restOptions}); - } catch (error) { - logError('Error checking changed files for React Compiler compliance:', error); - return false; + if (filesToCheck.length === 0) { + logSuccess('No React files changed, skipping check.'); + return true; } + + return check({filesToCheck, ...restOptions}); } function runCompilerHealthcheck(src?: string): CompilerResults { diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 57a63604e210..9d179b838c64 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -306,7 +306,7 @@ class Git { // Verify the ref is now available if (!this.isValidRef(ref)) { - throw new Error(`Reference ${ref} is still not valid after fetching`); + throw new Error(`Reference ${ref} is still not valid after fetching from remote ${remote}`); } } catch (error) { throw new Error(`Failed to fetch git reference ${ref}: ${error instanceof Error ? error.message : String(error)}`); @@ -407,15 +407,10 @@ class Git { return changedFiles.map((file) => file.filename); } - try { - // Get the diff output and check status - const diffResult = this.diff(fromRef, toRef); - const files = diffResult.files.map((file) => file.filePath); - return files; - } catch (error) { - logError('Could not determine changed files:', error); - throw error; - } + // Get the diff output and check status + const diffResult = this.diff(fromRef, toRef); + const files = diffResult.files.map((file) => file.filePath); + return files; } } From 4135708164c58fcd59d17922d7492626b9e37855 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:27:25 +0100 Subject: [PATCH 48/78] chore: make scripts use strict types --- scripts/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 5d4834efdc04..994ae5aaf9b6 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -4,6 +4,7 @@ "moduleResolution": "node", "target": "ES2023", "types": ["node"], + "strict": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "downlevelIteration": true, From 84ebb6f7dd66ea251b9792b9cc41cfde7642a9b4 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:27:42 +0100 Subject: [PATCH 49/78] refactor: extract base ref and use GITHUB_BASE_REF --- scripts/GITHUB_CONSTANTS.ts | 1 + scripts/utils/Git.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/GITHUB_CONSTANTS.ts b/scripts/GITHUB_CONSTANTS.ts index c4215ac01205..9b8fc75b1c12 100644 --- a/scripts/GITHUB_CONSTANTS.ts +++ b/scripts/GITHUB_CONSTANTS.ts @@ -1,6 +1,7 @@ const GITHUB_CONSTANTS = { GITHUB_OWNER: 'Expensify', GITHUB_REPO: 'App', + DEFAULT_BASE_REF: 'main', }; export default GITHUB_CONSTANTS; diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 9d179b838c64..efeb05bca46c 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -8,6 +8,7 @@ import {log, error as logError, warn as logWarn} from './Logger'; const exec = promisify(execWithCallback); const IS_CI = process.env.CI === 'true'; +const GITHUB_BASE_REF = process.env.GITHUB_BASE_REF as string | undefined; /** * Represents a single changed line in a git diff. @@ -314,15 +315,17 @@ class Git { } static async getMainBranchCommitHash(remote?: string): Promise { + const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? GITHUB_CONSTANTS.DEFAULT_BASE_REF) : GITHUB_CONSTANTS.DEFAULT_BASE_REF; + // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { - await this.ensureRef('main', remote); + await this.ensureRef(baseRefName, remote); } // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { - const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; + const mainBaseRef = remote ? `${remote}/${baseRefName}` : `origin/${baseRefName}`; try { const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { @@ -343,7 +346,7 @@ class Git { } } - const mainBaseRef = remote ? `${remote}/main` : 'main'; + const mainBaseRef = remote ? `${remote}/${baseRefName}` : baseRefName; // For local development, try to find the actual merge base let mergeBaseHash: string; From ebe3e1d410ae81b06cef04ad38cfd53428614b3f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:30:04 +0100 Subject: [PATCH 50/78] try ditching ensureRef --- scripts/utils/Git.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index efeb05bca46c..38e64ca73f5e 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -317,10 +317,7 @@ class Git { static async getMainBranchCommitHash(remote?: string): Promise { const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? GITHUB_CONSTANTS.DEFAULT_BASE_REF) : GITHUB_CONSTANTS.DEFAULT_BASE_REF; - // Fetch the main branch from the specified remote (or locally) to ensure it's available - if (IS_CI || remote) { - await this.ensureRef(baseRefName, remote); - } + execSync(`git fetch ${remote} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations From 9ae50fecadb6d31c10226492361087ce7fe31241 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:31:12 +0100 Subject: [PATCH 51/78] fix: fallback remote --- scripts/utils/Git.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 38e64ca73f5e..f28972242267 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -317,7 +317,7 @@ class Git { static async getMainBranchCommitHash(remote?: string): Promise { const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? GITHUB_CONSTANTS.DEFAULT_BASE_REF) : GITHUB_CONSTANTS.DEFAULT_BASE_REF; - execSync(`git fetch ${remote} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); + execSync(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations From ae32a4398ce958b13fc09309d579e99133ec9507 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:34:45 +0100 Subject: [PATCH 52/78] test exec git fetch --- scripts/utils/Git.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index f28972242267..1e77a6108b03 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -300,7 +300,7 @@ class Git { try { log(`🔄 Fetching missing ref: ${ref}`); - await exec(`git fetch --no-tags --depth=1 --quiet ${remote} ${ref}`, { + await exec(`git fetch ${remote} ${ref} --no-tags --depth=1 --quiet`, { encoding: 'utf8', cwd: process.cwd(), }); @@ -317,7 +317,11 @@ class Git { static async getMainBranchCommitHash(remote?: string): Promise { const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? GITHUB_CONSTANTS.DEFAULT_BASE_REF) : GITHUB_CONSTANTS.DEFAULT_BASE_REF; - execSync(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); + // Fetch the main branch from the specified remote (or locally) to ensure it's available + if (IS_CI || remote) { + // await this.ensureRef(baseRefName, remote); + await exec(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); + } // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations From df72e801053f70378437d1270208a66202980184 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 15 Oct 2025 17:36:20 +0100 Subject: [PATCH 53/78] fix: remove ensureRef usage --- scripts/utils/Git.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 1e77a6108b03..256a4fae2ec5 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -319,7 +319,6 @@ class Git { // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { - // await this.ensureRef(baseRefName, remote); await exec(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); } From 2a17cda77394299636e9c1e2937e293281720ddf Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 17 Oct 2025 11:49:07 +0100 Subject: [PATCH 54/78] chore: make concurrency group suffix-based --- .github/workflows/react-compiler-compliance.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/react-compiler-compliance.yml b/.github/workflows/react-compiler-compliance.yml index 8327139783d7..97f6f78b28ad 100644 --- a/.github/workflows/react-compiler-compliance.yml +++ b/.github/workflows/react-compiler-compliance.yml @@ -8,7 +8,7 @@ on: paths: ["**.tsx"] concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-react-compiler-compliance + group: react-compiler-compliance-${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }} cancel-in-progress: true jobs: react-compiler-compliance: From 1ec2716e600f8e27f47a46a0b2b6f619f3cc143c Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 17 Oct 2025 11:54:46 +0100 Subject: [PATCH 55/78] refactor: remove GITHUB_CONSTANTS file and use CONST instead --- .github/libs/CONST.ts | 5 ++++- .github/libs/GithubUtils.ts | 2 +- scripts/GITHUB_CONSTANTS.ts | 7 ------- scripts/aggregateGitHubDataFromUpwork.ts | 8 ++++---- scripts/utils/Git.ts | 8 ++++---- 5 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 scripts/GITHUB_CONSTANTS.ts diff --git a/.github/libs/CONST.ts b/.github/libs/CONST.ts index ad7711426ca3..3a2b61c79801 100644 --- a/.github/libs/CONST.ts +++ b/.github/libs/CONST.ts @@ -1,9 +1,12 @@ const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; + const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', } as const; const CONST = { diff --git a/.github/libs/GithubUtils.ts b/.github/libs/GithubUtils.ts index 281f1027d04c..a9983db69dc7 100644 --- a/.github/libs/GithubUtils.ts +++ b/.github/libs/GithubUtils.ts @@ -658,7 +658,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path: string, ref = 'main'): Promise { + static async getFileContents(path: string, ref = CONST.DEFAULT_BASE_REF): Promise { const {data} = await this.octokit.repos.getContent({ owner: CONST.GITHUB_OWNER, repo: CONST.APP_REPO, diff --git a/scripts/GITHUB_CONSTANTS.ts b/scripts/GITHUB_CONSTANTS.ts deleted file mode 100644 index 9b8fc75b1c12..000000000000 --- a/scripts/GITHUB_CONSTANTS.ts +++ /dev/null @@ -1,7 +0,0 @@ -const GITHUB_CONSTANTS = { - GITHUB_OWNER: 'Expensify', - GITHUB_REPO: 'App', - DEFAULT_BASE_REF: 'main', -}; - -export default GITHUB_CONSTANTS; diff --git a/scripts/aggregateGitHubDataFromUpwork.ts b/scripts/aggregateGitHubDataFromUpwork.ts index 45cbc6d3fc0d..aab8fcc613e8 100644 --- a/scripts/aggregateGitHubDataFromUpwork.ts +++ b/scripts/aggregateGitHubDataFromUpwork.ts @@ -12,7 +12,7 @@ import {paginateRest} from '@octokit/plugin-paginate-rest'; import {throttling} from '@octokit/plugin-throttling'; import {createObjectCsvWriter} from 'csv-writer'; import fs from 'fs'; -import GITHUB_CONSTANTS from './GITHUB_CONSTANTS'; +import CONST from '@github/libs/CONST'; type OctokitOptions = {method: string; url: string; request: {retryCount: number}}; type IssueType = 'bug' | 'feature' | 'other'; @@ -113,7 +113,7 @@ async function getProjectsForIssue(issueNumber: number): Promise { const response = await octokit.graphql( ` { - repository(owner: "${GITHUB_CONSTANTS.GITHUB_OWNER}", name: "${GITHUB_CONSTANTS.GITHUB_REPO}") { + repository(owner: "${CONST.GITHUB_OWNER}", name: "${CONST.APP_REPO}") { issue(number: ${issueNumber}) { projectsV2(last: 30) { nodes { @@ -135,8 +135,8 @@ async function getGitHubData() { console.info(`Fetching ${issueNumber}`); const result = await octokit.rest.issues .get({ - owner: GITHUB_CONSTANTS.GITHUB_OWNER, - repo: GITHUB_CONSTANTS.GITHUB_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, // eslint-disable-next-line @typescript-eslint/naming-convention issue_number: issueNumber, }) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 256a4fae2ec5..4fb39f15964e 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -1,8 +1,8 @@ import {context} from '@actions/github'; import {execSync, exec as execWithCallback} from 'child_process'; import {promisify} from 'util'; +import CONST from '@github/libs/CONST'; import GitHubUtils from '@github/libs/GithubUtils'; -import GITHUB_CONSTANTS from '@scripts/GITHUB_CONSTANTS'; import {log, error as logError, warn as logWarn} from './Logger'; const exec = promisify(execWithCallback); @@ -315,7 +315,7 @@ class Git { } static async getMainBranchCommitHash(remote?: string): Promise { - const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? GITHUB_CONSTANTS.DEFAULT_BASE_REF) : GITHUB_CONSTANTS.DEFAULT_BASE_REF; + const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? CONST.DEFAULT_BASE_REF) : CONST.DEFAULT_BASE_REF; // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { @@ -401,8 +401,8 @@ class Git { static async getChangedFileNames(fromRef: string, toRef = 'HEAD'): Promise { if (IS_CI) { const {data: changedFiles} = await GitHubUtils.octokit.pulls.listFiles({ - owner: GITHUB_CONSTANTS.GITHUB_OWNER, - repo: GITHUB_CONSTANTS.GITHUB_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, // eslint-disable-next-line @typescript-eslint/naming-convention pull_number: context.payload.pull_request?.number ?? 0, }); From a5fdb6d3022eabc641b2b7ad6d2280adc54cb230 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 17 Oct 2025 11:54:56 +0100 Subject: [PATCH 56/78] style: remove empty line --- .github/workflows/react-compiler-compliance.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/react-compiler-compliance.yml b/.github/workflows/react-compiler-compliance.yml index 97f6f78b28ad..24260c80a0af 100644 --- a/.github/workflows/react-compiler-compliance.yml +++ b/.github/workflows/react-compiler-compliance.yml @@ -15,7 +15,6 @@ jobs: name: React Compiler Compliance if: ${{ github.actor != 'OSBotify' }} runs-on: ubuntu-latest - steps: # v4 - name: Checkout From c4201fbc270a729a4783f962e779561c158c018d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 17 Oct 2025 12:31:02 +0100 Subject: [PATCH 57/78] feat: add default options to exec wrapper --- scripts/utils/Git.ts | 67 ++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 4fb39f15964e..1b761b8331cf 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -1,11 +1,36 @@ import {context} from '@actions/github'; -import {execSync, exec as execWithCallback} from 'child_process'; +import {exec as execWithCallback, execSync as originalExecSync} from 'child_process'; +import type {ExecSyncOptionsWithStringEncoding, ExecOptions as ExecWithCallbackOptions} from 'child_process'; import {promisify} from 'util'; import CONST from '@github/libs/CONST'; import GitHubUtils from '@github/libs/GithubUtils'; import {log, error as logError, warn as logWarn} from './Logger'; -const exec = promisify(execWithCallback); +type ExecOptions = Omit & {cwd?: ExecWithCallbackOptions['cwd']}; +function exec(command: string, options?: ExecOptions) { + const optionsWithEncoding = { + ...options, + encoding: 'utf8', + cwd: process.cwd(), + }; + + return promisify(execWithCallback)(command, optionsWithEncoding); +} + +type ExecSyncOptions = Omit & { + encoding?: ExecSyncOptionsWithStringEncoding['encoding']; + cwd?: ExecSyncOptionsWithStringEncoding['cwd']; +}; + +function execSync(command: string, options?: ExecSyncOptions) { + const optionsWithEncoding: ExecSyncOptionsWithStringEncoding = { + ...options, + encoding: 'utf8', + cwd: process.cwd(), + }; + + return originalExecSync(command, optionsWithEncoding); +} const IS_CI = process.env.CI === 'true'; const GITHUB_BASE_REF = process.env.GITHUB_BASE_REF as string | undefined; @@ -63,8 +88,6 @@ class Git { static isValidRef(ref: string): boolean { try { execSync(`git rev-parse --verify "${ref}^{object}"`, { - encoding: 'utf8', - cwd: process.cwd(), stdio: 'pipe', // Suppress output }); return true; @@ -95,10 +118,7 @@ class Git { } // Execute git diff with unified format - let errors bubble up - const diffOutput = execSync(command, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const diffOutput = execSync(command); return Git.parseDiff(diffOutput); } @@ -280,7 +300,7 @@ class Git { */ static show(ref: string, filePath: string): string { try { - return execSync(`git show ${ref}:${filePath}`, {encoding: 'utf8'}); + return execSync(`git show ${ref}:${filePath}`); } catch (error) { throw new Error(`Failed to get file content from git: ${error instanceof Error ? error.message : String(error)}`); } @@ -300,10 +320,7 @@ class Git { try { log(`🔄 Fetching missing ref: ${ref}`); - await exec(`git fetch ${remote} ${ref} --no-tags --depth=1 --quiet`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + await exec(`git fetch ${remote} ${ref} --no-tags --depth=1 --quiet`); // Verify the ref is now available if (!this.isValidRef(ref)) { @@ -315,11 +332,11 @@ class Git { } static async getMainBranchCommitHash(remote?: string): Promise { - const baseRefName = IS_CI ? (GITHUB_BASE_REF ?? CONST.DEFAULT_BASE_REF) : CONST.DEFAULT_BASE_REF; + const baseRefName = GITHUB_BASE_REF ?? CONST.DEFAULT_BASE_REF; // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { - await exec(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1 -q`, {encoding: 'utf8'}); + await exec(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1`); } // In CI, use a simpler approach - just use the remote main branch directly @@ -328,10 +345,7 @@ class Git { const mainBaseRef = remote ? `${remote}/${baseRefName}` : `origin/${baseRefName}`; try { - const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`); const mergeBaseHash = revParseOutput.trim(); // Validate the output is a proper SHA hash @@ -351,20 +365,14 @@ class Git { // For local development, try to find the actual merge base let mergeBaseHash: string; try { - const {stdout: mergeBaseOutput} = await exec(`git merge-base ${mainBaseRef} HEAD`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const {stdout: mergeBaseOutput} = await exec(`git merge-base ${mainBaseRef} HEAD`); mergeBaseHash = mergeBaseOutput.trim(); } catch { logWarn(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const {stdout: revParseOutput} = await exec(`git rev-parse ${mainBaseRef}`); mergeBaseHash = revParseOutput.trim(); } catch (fallbackError) { logError(`Failed to find merge base with ${mainBaseRef}:`, fallbackError); @@ -387,10 +395,7 @@ class Git { */ static async hasUncommittedChanges(): Promise { try { - const {stdout} = await exec('git status --porcelain', { - encoding: 'utf8', - cwd: process.cwd(), - }); + const {stdout} = await exec('git status --porcelain'); const status = stdout.trim(); return status.length > 0; } catch (error) { From a8f26d1636f6438b98a6531a8fb1f441135ad04c Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 17 Oct 2025 12:33:05 +0100 Subject: [PATCH 58/78] refactor: remove duplicate type alias --- scripts/react-compiler-compliance-check.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index b093a0ce28ac..4f3fcc75e996 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -56,14 +56,14 @@ type PrintResultsOptions = { shouldPrintSuccesses: boolean; }; -type CommonCheckOptions = PrintResultsOptions & { +type BaseCheckOptions = PrintResultsOptions & { remote?: string; reportFileName?: string; shouldGenerateReport?: boolean; shouldFilterByDiff?: boolean; }; -type CheckOptions = CommonCheckOptions & { +type CheckOptions = BaseCheckOptions & { filesToCheck?: string[]; }; @@ -101,9 +101,7 @@ async function check({ return isPassed; } -type CheckChangedFilesOptions = CommonCheckOptions; - -async function checkChangedFiles({remote, ...restOptions}: CheckChangedFilesOptions): Promise { +async function checkChangedFiles({remote, ...restOptions}: BaseCheckOptions): Promise { logInfo('Checking changed files for React Compiler compliance...'); const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); @@ -540,7 +538,7 @@ async function main() { const {remote, reportFileName} = cli.namedArgs; const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff, printSuccesses: shouldPrintSuccesses} = cli.flags; - const commonOptions: CommonCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; + const commonOptions: BaseCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; async function runCommand() { switch (command) { From badc901709c9ee0d28ac7879ad496632fc2bba48 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 17 Oct 2025 12:33:51 +0100 Subject: [PATCH 59/78] refactor: remove redundant local variable --- scripts/react-compiler-compliance-check.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 4f3fcc75e996..4aec9308807b 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -129,8 +129,7 @@ function runCompilerHealthcheck(src?: string): CompilerResults { cwd: process.cwd(), }); - const results = parseHealthcheckOutput(output); - return results; + return parseHealthcheckOutput(output); } function parseHealthcheckOutput(output: string): CompilerResults { From 9fdaaddf3e5274cf97a50d8ed09501ec34d0318d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sat, 18 Oct 2025 17:48:26 +0100 Subject: [PATCH 60/78] fix: new react-compiler error --- .../SelectionListWithSections/BaseSelectionListWithSections.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx b/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx index ad51e201a581..a0368bc60368 100644 --- a/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx +++ b/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx @@ -725,7 +725,7 @@ function BaseSelectionListWithSections({ if (typeof textInputRef === 'function') { textInputRef(element as RNTextInput); } else { - // eslint-disable-next-line no-param-reassign + // eslint-disable-next-line no-param-reassign, react-compiler/react-compiler textInputRef.current = element as RNTextInput; } }} From 039ee5ab485904fe3e595a580ec2d145844cb852 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sat, 18 Oct 2025 17:48:58 +0100 Subject: [PATCH 61/78] fix: remove intentional react-compiler error --- src/components/AddPlaidBankAccount.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index a549d55671bd..4c50576b5417 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -80,7 +80,6 @@ function AddPlaidBankAccount({ const defaultSelectedPlaidAccountID = defaultSelectedPlaidAccount?.plaidAccountID; const defaultSelectedPlaidAccountMask = plaidBankAccounts.find((account) => account.plaidAccountID === selectedPlaidAccountID)?.mask ?? ''; const subscribedKeyboardShortcuts = useRef void>>([]); - subscribedKeyboardShortcuts.current = []; const previousNetworkState = useRef(undefined); const [selectedPlaidAccountMask, setSelectedPlaidAccountMask] = useState(defaultSelectedPlaidAccountMask); const [plaidLinkToken] = useOnyx(ONYXKEYS.PLAID_LINK_TOKEN, {canBeMissing: true, initWithStoredValues: false}); From e36fdffde609fe39344f481766d2936effd108a3 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sat, 18 Oct 2025 17:51:09 +0100 Subject: [PATCH 62/78] chore: run `npm run gh-actions-build` --- .../javascript/authorChecklist/index.js | 6 +- .../javascript/awaitStagingDeploys/index.js | 6 +- .../javascript/checkAndroidStatus/index.js | 6 +- .../javascript/checkDeployBlockers/index.js | 6 +- .../javascript/checkSVGCompression/index.js | 6 +- .../createOrUpdateStagingDeploy/index.js | 6 +- .../javascript/getArtifactInfo/index.js | 6 +- .../getDeployPullRequestList/index.js | 6 +- .../javascript/getPreviousVersion/index.js | 6 +- .../javascript/getPullRequestDetails/index.js | 6 +- .../getPullRequestIncrementalChanges/index.js | 90 +++++++++---------- .../javascript/isStagingDeployLocked/index.js | 6 +- .../markPullRequestsAsDeployed/index.js | 6 +- .../javascript/postTestBuildComment/index.js | 6 +- .../javascript/proposalPoliceComment/index.js | 6 +- .../reopenIssueWithComment/index.js | 6 +- .../javascript/reviewerChecklist/index.js | 6 +- .../javascript/verifySignedCommits/index.js | 6 +- 18 files changed, 110 insertions(+), 82 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 214f324839ed..411cc83e799c 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -15540,10 +15540,12 @@ exports["default"] = newComponentCategory; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -16127,7 +16129,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/awaitStagingDeploys/index.js b/.github/actions/javascript/awaitStagingDeploys/index.js index 7ae106487882..8ffaac81af7a 100644 --- a/.github/actions/javascript/awaitStagingDeploys/index.js +++ b/.github/actions/javascript/awaitStagingDeploys/index.js @@ -12344,10 +12344,12 @@ function convertToNumber(value) { Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12931,7 +12933,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/checkAndroidStatus/index.js b/.github/actions/javascript/checkAndroidStatus/index.js index fbfb62f9636f..bcb2fb90dfdf 100644 --- a/.github/actions/javascript/checkAndroidStatus/index.js +++ b/.github/actions/javascript/checkAndroidStatus/index.js @@ -737087,10 +737087,12 @@ checkAndroidStatus() Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -737674,7 +737676,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/checkDeployBlockers/index.js b/.github/actions/javascript/checkDeployBlockers/index.js index 36e405f2315a..e3762414978d 100644 --- a/.github/actions/javascript/checkDeployBlockers/index.js +++ b/.github/actions/javascript/checkDeployBlockers/index.js @@ -11611,10 +11611,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12198,7 +12200,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/checkSVGCompression/index.js b/.github/actions/javascript/checkSVGCompression/index.js index a0aec4f728a5..73d3aa1f1a63 100644 --- a/.github/actions/javascript/checkSVGCompression/index.js +++ b/.github/actions/javascript/checkSVGCompression/index.js @@ -20136,10 +20136,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -20723,7 +20725,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index fa3e042e4885..7c46ed86022b 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -11739,10 +11739,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12485,7 +12487,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/getArtifactInfo/index.js b/.github/actions/javascript/getArtifactInfo/index.js index dad4ab512a3a..c239d1756e0a 100644 --- a/.github/actions/javascript/getArtifactInfo/index.js +++ b/.github/actions/javascript/getArtifactInfo/index.js @@ -11572,10 +11572,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12159,7 +12161,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 4990c6d5a805..86807369ae9d 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11758,10 +11758,12 @@ function convertToNumber(value) { Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12504,7 +12506,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/getPreviousVersion/index.js b/.github/actions/javascript/getPreviousVersion/index.js index c4a2a47fb5ec..950e9c7b157f 100644 --- a/.github/actions/javascript/getPreviousVersion/index.js +++ b/.github/actions/javascript/getPreviousVersion/index.js @@ -11569,10 +11569,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12315,7 +12317,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/getPullRequestDetails/index.js b/.github/actions/javascript/getPullRequestDetails/index.js index 028bf6dd3c4c..b731a960a7ef 100644 --- a/.github/actions/javascript/getPullRequestDetails/index.js +++ b/.github/actions/javascript/getPullRequestDetails/index.js @@ -11701,10 +11701,12 @@ function convertToNumber(value) { Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12288,7 +12290,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js index a1032bc6f641..f1c47b5e1ed5 100644 --- a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js +++ b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js @@ -11803,10 +11803,12 @@ function convertToNumber(value) { Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12390,7 +12392,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, @@ -12539,10 +12541,27 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); const github_1 = __nccwpck_require__(5438); const child_process_1 = __nccwpck_require__(2081); const util_1 = __nccwpck_require__(3837); +const CONST_1 = __importDefault(__nccwpck_require__(9873)); const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); const Logger_1 = __nccwpck_require__(8891); -const exec = (0, util_1.promisify)(child_process_1.exec); +function exec(command, options) { + const optionsWithEncoding = { + ...options, + encoding: 'utf8', + cwd: process.cwd(), + }; + return (0, util_1.promisify)(child_process_1.exec)(command, optionsWithEncoding); +} +function execSync(command, options) { + const optionsWithEncoding = { + ...options, + encoding: 'utf8', + cwd: process.cwd(), + }; + return (0, child_process_1.execSync)(command, optionsWithEncoding); +} const IS_CI = process.env.CI === 'true'; +const GITHUB_BASE_REF = process.env.GITHUB_BASE_REF; /** * Utility class for git operations. */ @@ -12555,9 +12574,7 @@ class Git { */ static isValidRef(ref) { try { - (0, child_process_1.execSync)(`git rev-parse --verify "${ref}^{object}"`, { - encoding: 'utf8', - cwd: process.cwd(), + execSync(`git rev-parse --verify "${ref}^{object}"`, { stdio: 'pipe', // Suppress output }); return true; @@ -12587,10 +12604,7 @@ class Git { command += ` -- ${quotedPaths}`; } // Execute git diff with unified format - let errors bubble up - const diffOutput = (0, child_process_1.execSync)(command, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const diffOutput = execSync(command); return Git.parseDiff(diffOutput); } /** @@ -12753,7 +12767,7 @@ class Git { */ static show(ref, filePath) { try { - return (0, child_process_1.execSync)(`git show ${ref}:${filePath}`, { encoding: 'utf8' }); + return execSync(`git show ${ref}:${filePath}`); } catch (error) { throw new Error(`Failed to get file content from git: ${error instanceof Error ? error.message : String(error)}`); @@ -12772,13 +12786,10 @@ class Git { } try { (0, Logger_1.log)(`🔄 Fetching missing ref: ${ref}`); - await exec(`git fetch --no-tags --depth=1 --quiet ${remote} ${ref}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + await exec(`git fetch ${remote} ${ref} --no-tags --depth=1 --quiet`); // Verify the ref is now available if (!this.isValidRef(ref)) { - throw new Error(`Reference ${ref} is still not valid after fetching`); + throw new Error(`Reference ${ref} is still not valid after fetching from remote ${remote}`); } } catch (error) { @@ -12786,19 +12797,17 @@ class Git { } } static async getMainBranchCommitHash(remote) { + const baseRefName = GITHUB_BASE_REF ?? CONST_1.default.DEFAULT_BASE_REF; // Fetch the main branch from the specified remote (or locally) to ensure it's available if (IS_CI || remote) { - await this.ensureRef('main', remote); + await exec(`git fetch ${remote ?? 'origin'} ${baseRefName} --no-tags --depth=1`); } // In CI, use a simpler approach - just use the remote main branch directly // This avoids issues with shallow clones and merge-base calculations if (IS_CI) { - const mainBaseRef = remote ? `${remote}/main` : 'origin/main'; + const mainBaseRef = remote ? `${remote}/${baseRefName}` : `origin/${baseRefName}`; try { - const { stdout: revParseOutput } = await exec(`git rev-parse ${mainBaseRef}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const { stdout: revParseOutput } = await exec(`git rev-parse ${mainBaseRef}`); const mergeBaseHash = revParseOutput.trim(); // Validate the output is a proper SHA hash if (!mergeBaseHash || !/^[a-fA-F0-9]{40}$/.test(mergeBaseHash)) { @@ -12811,24 +12820,18 @@ class Git { throw new Error(`Could not get commit hash for ${mainBaseRef}`); } } - const mainBaseRef = remote ? `${remote}/main` : 'main'; + const mainBaseRef = remote ? `${remote}/${baseRefName}` : baseRefName; // For local development, try to find the actual merge base let mergeBaseHash; try { - const { stdout: mergeBaseOutput } = await exec(`git merge-base ${mainBaseRef} HEAD`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const { stdout: mergeBaseOutput } = await exec(`git merge-base ${mainBaseRef} HEAD`); mergeBaseHash = mergeBaseOutput.trim(); } catch { (0, Logger_1.warn)(`Warning: Could not find merge base between ${mainBaseRef} and HEAD.`); // If merge-base fails locally, fall back to using the remote main branch try { - const { stdout: revParseOutput } = await exec(`git rev-parse ${mainBaseRef}`, { - encoding: 'utf8', - cwd: process.cwd(), - }); + const { stdout: revParseOutput } = await exec(`git rev-parse ${mainBaseRef}`); mergeBaseHash = revParseOutput.trim(); } catch (fallbackError) { @@ -12849,10 +12852,7 @@ class Git { */ static async hasUncommittedChanges() { try { - const { stdout } = await exec('git status --porcelain', { - encoding: 'utf8', - cwd: process.cwd(), - }); + const { stdout } = await exec('git status --porcelain'); const status = stdout.trim(); return status.length > 0; } @@ -12860,26 +12860,20 @@ class Git { return false; } } - static async getChangedFiles(fromRef, toRef = 'HEAD') { + static async getChangedFileNames(fromRef, toRef = 'HEAD') { if (IS_CI) { const { data: changedFiles } = await GithubUtils_1.default.octokit.pulls.listFiles({ - owner: 'Expensify', - repo: 'App', + owner: CONST_1.default.GITHUB_OWNER, + repo: CONST_1.default.APP_REPO, // eslint-disable-next-line @typescript-eslint/naming-convention pull_number: github_1.context.payload.pull_request?.number ?? 0, }); return changedFiles.map((file) => file.filename); } - try { - // Get the diff output and check status - const diffResult = this.diff(fromRef, toRef); - const files = diffResult.files.map((file) => file.filePath); - return files; - } - catch (error) { - (0, Logger_1.error)('Could not determine changed files:', error); - throw error; - } + // Get the diff output and check status + const diffResult = this.diff(fromRef, toRef); + const files = diffResult.files.map((file) => file.filePath); + return files; } } exports["default"] = Git; diff --git a/.github/actions/javascript/isStagingDeployLocked/index.js b/.github/actions/javascript/isStagingDeployLocked/index.js index 17426f649697..f11329ae4f3a 100644 --- a/.github/actions/javascript/isStagingDeployLocked/index.js +++ b/.github/actions/javascript/isStagingDeployLocked/index.js @@ -11572,10 +11572,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12159,7 +12161,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/index.js b/.github/actions/javascript/markPullRequestsAsDeployed/index.js index 4fde88d74dfe..0a44de160bda 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/index.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/index.js @@ -13025,10 +13025,12 @@ function convertToNumber(value) { Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -13612,7 +13614,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 22d189a62061..e2bb6cd44d57 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11702,10 +11702,12 @@ exports["default"] = run; Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12289,7 +12291,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/proposalPoliceComment/index.js b/.github/actions/javascript/proposalPoliceComment/index.js index 911a29aa867a..26fffecafca1 100644 --- a/.github/actions/javascript/proposalPoliceComment/index.js +++ b/.github/actions/javascript/proposalPoliceComment/index.js @@ -11841,10 +11841,12 @@ function convertToNumber(value) { Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12428,7 +12430,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/reopenIssueWithComment/index.js b/.github/actions/javascript/reopenIssueWithComment/index.js index 4ba4badaa52e..25f1900a0c6e 100644 --- a/.github/actions/javascript/reopenIssueWithComment/index.js +++ b/.github/actions/javascript/reopenIssueWithComment/index.js @@ -11582,10 +11582,12 @@ reopenIssueWithComment() Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12169,7 +12171,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index cb29c2546ce9..d32742027f2a 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -11674,10 +11674,12 @@ getNumberOfItemsFromReviewerChecklist() Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12261,7 +12263,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, diff --git a/.github/actions/javascript/verifySignedCommits/index.js b/.github/actions/javascript/verifySignedCommits/index.js index 5ea3b9bdd64a..62087cfde03a 100644 --- a/.github/actions/javascript/verifySignedCommits/index.js +++ b/.github/actions/javascript/verifySignedCommits/index.js @@ -11614,10 +11614,12 @@ GithubUtils_1.default.octokit.pulls Object.defineProperty(exports, "__esModule", ({ value: true })); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); +const DEFAULT_REPO_IDENTIFIER = 'Expensify/App'; const GIT_CONST = { GITHUB_OWNER: process.env.GITHUB_REPOSITORY_OWNER ?? 'Expensify', - APP_REPO: (process.env.GITHUB_REPOSITORY ?? 'Expensify/App').split('/').at(1) ?? '', + APP_REPO: (process.env.GITHUB_REPOSITORY ?? DEFAULT_REPO_IDENTIFIER).split('/').at(1) ?? '', MOBILE_EXPENSIFY_REPO: 'Mobile-Expensify', + DEFAULT_BASE_REF: 'main', }; const CONST = { ...GIT_CONST, @@ -12201,7 +12203,7 @@ class GithubUtils { /** * Get the contents of a file from the API at a given ref as a string. */ - static async getFileContents(path, ref = 'main') { + static async getFileContents(path, ref = CONST_1.default.DEFAULT_BASE_REF) { const { data } = await this.octokit.repos.getContent({ owner: CONST_1.default.GITHUB_OWNER, repo: CONST_1.default.APP_REPO, From 52eb6527298f56bf3a81f378a40390bbe8fd752d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sun, 19 Oct 2025 13:13:28 +0100 Subject: [PATCH 63/78] fix: remove json parsing to fix error suppression --- scripts/react-compiler-compliance-check.ts | 100 +++++---------------- 1 file changed, 22 insertions(+), 78 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 4aec9308807b..9ed46c3d924c 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -30,11 +30,6 @@ const VERBOSE_OUTPUT_LINE_REGEXES = { REASON: /Reason: (.+)/, } as const satisfies Record; -type HealthcheckJsonResults = { - success: string[]; - failure: string[]; -}; - type CompilerResults = { success: Set; failures: Map; @@ -123,83 +118,30 @@ function runCompilerHealthcheck(src?: string): CompilerResults { srcString = srcString?.endsWith('"') ? srcString : `${srcString}"`; } - const command = `npx react-compiler-healthcheck ${src ? `--src ${srcString}` : ''} --json --verbose `; + const command = `npx react-compiler-healthcheck ${src ? `--src ${srcString}` : ''} --verbose `; const output = execSync(command, { encoding: 'utf8', cwd: process.cwd(), }); + console.log(output); + return parseHealthcheckOutput(output); } function parseHealthcheckOutput(output: string): CompilerResults { const lines = output.split('\n'); - const initialResults: CompilerResults = { + const results: CompilerResults = { success: new Set(), failures: new Map(), }; - const verboseResults = parseVerboseOutput(lines, initialResults); - const finalResults = parseJsonOutput(lines, verboseResults); - - return finalResults; -} - -function parseJsonOutput(lines: string[], results: CompilerResults): CompilerResults { - let jsonStart = -1; - let jsonEnd = -1; - for (let i = 0; i < lines.length; i++) { - if (lines.at(i)?.trim().startsWith('{')) { - jsonStart = i; - } - if (jsonStart !== -1 && lines.at(i)?.trim().endsWith('}')) { - jsonEnd = i; - break; - } - } - - if (jsonStart === -1 || jsonEnd === -1) { - logWarn('No JSON found in combined output, parsing verbose text only'); - - return results; - } - - // Parse JSON if found - try { - const jsonLines = lines.slice(jsonStart, jsonEnd + 1); - const jsonStr = jsonLines.join('\n'); - const jsonResult = JSON.parse(jsonStr) as HealthcheckJsonResults; - - // Process successful compilations from JSON - jsonResult.success.forEach((successfulFile) => results.success.add(successfulFile)); - - // Process failures from JSON - jsonResult.failure.forEach((failedFile) => { - // Get all failures for this file (all lines and columns) - const fileFailures = Array.from(results.failures.entries()).filter(([, failure]) => failure.file === failedFile); - - // Only add JSON file failure if no failure for this file exists already (all lines and columns) - if (fileFailures.length > 0) { - return; - } - - const newFailure: CompilerFailure = { - file: failedFile, - }; - const key = getUniqueFileKey(newFailure); - results.failures.set(key, newFailure); - }); - } catch (error) { - logWarn('Failed to parse JSON from combined react-compiler-healthcheck output:', error); - } - - return results; -} + const suppressedErrorFileKeys = new Set(); -function parseVerboseOutput(lines: string[], results: CompilerResults): CompilerResults { let currentFailureWithoutReason: CompilerFailure | null = null; + // Parse verbose output for (const line of lines) { // Parse successful file paths const successMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.SUCCESS); @@ -218,16 +160,17 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler column: parseInt(failureWithReasonMatch[3], 10), reason: failureWithReasonMatch[4], }; + const key = getUniqueFileKey(newFailure); // If we already have a reason, we don't want to set the reason again currentFailureWithoutReason = null; if (shouldSuppressCompilerError(newFailure.reason)) { + suppressedErrorFileKeys.add(getUniqueFileKey(newFailure)); continue; } // Only add if not already exists, or if existing one has no reason - const key = getUniqueFileKey(newFailure); const existing = results.failures.get(key); if (!existing?.reason) { results.failures.set(key, newFailure); @@ -237,17 +180,17 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler } // Parse failed compilation with file and location only (fallback) - const failureMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.FAILURE_WITHOUT_REASON); - if (failureMatch) { + const failureWithoutReasonMatch = line.match(VERBOSE_OUTPUT_LINE_REGEXES.FAILURE_WITHOUT_REASON); + if (failureWithoutReasonMatch) { const newFailure: CompilerFailure = { - file: failureMatch[1], - line: parseInt(failureMatch[2], 10), - column: parseInt(failureMatch[3], 10), + file: failureWithoutReasonMatch[1], + line: parseInt(failureWithoutReasonMatch[2], 10), + column: parseInt(failureWithoutReasonMatch[3], 10), }; // Only create new failure if it doesn't exist const key = getUniqueFileKey(newFailure); - if (results.failures.has(key)) { + if (results.failures.has(key) || suppressedErrorFileKeys.has(key)) { continue; } @@ -267,19 +210,20 @@ function parseVerboseOutput(lines: string[], results: CompilerResults): Compiler continue; } - if (shouldSuppressCompilerError(reason)) { - currentFailureWithoutReason = null; - continue; - } - - const newFailure: CompilerFailure = { + const currentFailure: CompilerFailure = { file: currentFailureWithoutReason.file, line: currentFailureWithoutReason.line, column: currentFailureWithoutReason.column, reason, }; + const currentFailureKey = getUniqueFileKey(currentFailure); + + if (shouldSuppressCompilerError(reason) || suppressedErrorFileKeys.has(currentFailureKey)) { + currentFailureWithoutReason = null; + continue; + } - results.failures.set(getUniqueFileKey(newFailure), newFailure); + results.failures.set(currentFailureKey, currentFailure); currentFailureWithoutReason = null; continue; From d39942b5f7c82dc1bb5dfc217441bb897a4bc5c2 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sun, 19 Oct 2025 13:15:30 +0100 Subject: [PATCH 64/78] fix: ESLint error --- .../SelectionListWithSections/BaseSelectionListWithSections.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx b/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx index a0368bc60368..31d1b7d21817 100644 --- a/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx +++ b/src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx @@ -745,7 +745,7 @@ function BaseSelectionListWithSections({ spellCheck={false} iconLeft={textInputIconLeft} onSubmitEditing={selectFocusedOption} - blurOnSubmit={!!flattenedSections.allOptions.length} + submitBehavior={flattenedSections.allOptions.length ? 'blurAndSubmit' : 'submit'} isLoading={isLoadingNewOptions} testID="selection-list-text-input" shouldInterceptSwipe={shouldTextInputInterceptSwipe} From 2a897b8ddc5d07fdf665b07884fe9aa48a282115 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sun, 19 Oct 2025 13:16:06 +0100 Subject: [PATCH 65/78] fix: remove duplicate workflow file --- .../react-compiler-compliance-v2.yml | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 .github/workflows/react-compiler-compliance-v2.yml diff --git a/.github/workflows/react-compiler-compliance-v2.yml b/.github/workflows/react-compiler-compliance-v2.yml deleted file mode 100644 index 88bdeba70ded..000000000000 --- a/.github/workflows/react-compiler-compliance-v2.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: React Compiler Compliance Check v2 - -on: - workflow_call: - pull_request: - types: [opened, synchronize] - branches-ignore: [staging, production] - paths: ["**.tsx"] - -concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-react-compiler-compliance - cancel-in-progress: true -jobs: - react-compiler-compliance: - name: React Compiler Compliance - if: ${{ github.actor != 'OSBotify' }} - runs-on: ubuntu-latest - - steps: - # v4 - - name: Checkout - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - - name: Setup Node - uses: ./.github/actions/composite/setupNode - - - name: Run React Compiler Compliance Check - run: npm run react-compiler-compliance-check check-changed --filterByDiff - env: - CI: true - GITHUB_TOKEN: ${{ github.token }} From b21352a53296a3995b27e4a28223420334bb98f1 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Sun, 19 Oct 2025 13:16:34 +0100 Subject: [PATCH 66/78] fix: remove console.log --- scripts/react-compiler-compliance-check.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 9ed46c3d924c..395be2806873 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -124,8 +124,6 @@ function runCompilerHealthcheck(src?: string): CompilerResults { cwd: process.cwd(), }); - console.log(output); - return parseHealthcheckOutput(output); } From cb677f49143d35339b12a6cba864ee40a920c533 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 11:34:58 +0100 Subject: [PATCH 67/78] fix: warn emoji CLI spacing --- scripts/utils/Logger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/Logger.ts b/scripts/utils/Logger.ts index 4666f776dee4..dc5a366ca565 100644 --- a/scripts/utils/Logger.ts +++ b/scripts/utils/Logger.ts @@ -8,10 +8,10 @@ const COLOR_BOLD = '\x1b[1m'; const EMOJIS = { // One column emojis need to be rendered with an extra space after to align with two column emojis INFO: '▶️ ', + WARN: '⚠️ ', // Two column emojis can be rendered as-is SUCCESS: '✅', - WARN: '⚠️', ERROR: '🔴', }; From 0bf7036d4ecb7da78ce75c24f2452350b4d03a24 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 11:35:09 +0100 Subject: [PATCH 68/78] feat: log suppressed warnings --- .../workflows/react-compiler-compliance.yml | 2 +- scripts/react-compiler-compliance-check.ts | 158 ++++++++++++------ 2 files changed, 109 insertions(+), 51 deletions(-) diff --git a/.github/workflows/react-compiler-compliance.yml b/.github/workflows/react-compiler-compliance.yml index 24260c80a0af..1a7f42ff01ac 100644 --- a/.github/workflows/react-compiler-compliance.yml +++ b/.github/workflows/react-compiler-compliance.yml @@ -24,7 +24,7 @@ jobs: uses: ./.github/actions/composite/setupNode - name: Run React Compiler Compliance Check - run: npm run react-compiler-compliance-check check-changed --filterByDiff + run: npm run react-compiler-compliance-check check-changed --filterByDiff --printSuppressedErrors env: CI: true GITHUB_TOKEN: ${{ github.token }} diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 395be2806873..9a12ff60cf1e 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -15,6 +15,8 @@ import Git from './utils/Git'; import type {DiffResult} from './utils/Git'; import {log, bold as logBold, error as logError, info as logInfo, note as logNote, success as logSuccess, warn as logWarn} from './utils/Logger'; +const TAB = ' '; + const DEFAULT_REPORT_FILENAME = 'react-compiler-report.json'; const SUPPRESSED_COMPILER_ERRORS = [ @@ -30,9 +32,12 @@ const VERBOSE_OUTPUT_LINE_REGEXES = { REASON: /Reason: (.+)/, } as const satisfies Record; +type FailureMap = Map; + type CompilerResults = { success: Set; - failures: Map; + failures: FailureMap; + suppressedFailures: FailureMap; }; type CompilerFailure = { @@ -49,6 +54,7 @@ type DiffFilteringCommits = { type PrintResultsOptions = { shouldPrintSuccesses: boolean; + shouldPrintSuppressedErrors: boolean; }; type BaseCheckOptions = PrintResultsOptions & { @@ -69,6 +75,7 @@ async function check({ shouldFilterByDiff = false, remote, shouldPrintSuccesses = false, + shouldPrintSuppressedErrors = false, }: CheckOptions): Promise { if (filesToCheck) { logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); @@ -83,10 +90,10 @@ async function check({ const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); const headCommitHash = 'HEAD'; const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; - results = await filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses}); + results = await filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses, shouldPrintSuppressedErrors}); } - printResults(results, {shouldPrintSuccesses}); + printResults(results, {shouldPrintSuccesses, shouldPrintSuppressedErrors}); if (shouldGenerateReport) { generateReport(results, reportFileName); @@ -127,16 +134,29 @@ function runCompilerHealthcheck(src?: string): CompilerResults { return parseHealthcheckOutput(output); } +// eslint-disable-next-line rulesdir/no-negated-variables +function addIfDoesNotExist(failureMap: FailureMap, failure: CompilerFailure, shouldOnlyAddIfNoReason: boolean): boolean { + const key = getUniqueFileKey(failure); + if (failureMap.has(key)) { + if (shouldOnlyAddIfNoReason && failureMap.get(key)?.reason) { + return false; + } + return false; + } + + failureMap.set(key, failure); + return true; +} + function parseHealthcheckOutput(output: string): CompilerResults { const lines = output.split('\n'); const results: CompilerResults = { success: new Set(), failures: new Map(), + suppressedFailures: new Map(), }; - const suppressedErrorFileKeys = new Set(); - let currentFailureWithoutReason: CompilerFailure | null = null; // Parse verbose output @@ -158,23 +178,17 @@ function parseHealthcheckOutput(output: string): CompilerResults { column: parseInt(failureWithReasonMatch[3], 10), reason: failureWithReasonMatch[4], }; - const key = getUniqueFileKey(newFailure); // If we already have a reason, we don't want to set the reason again currentFailureWithoutReason = null; if (shouldSuppressCompilerError(newFailure.reason)) { - suppressedErrorFileKeys.add(getUniqueFileKey(newFailure)); + addIfDoesNotExist(results.suppressedFailures, newFailure, true); continue; } - // Only add if not already exists, or if existing one has no reason - const existing = results.failures.get(key); - if (!existing?.reason) { - results.failures.set(key, newFailure); - } - - continue; + // Only add if failure does not exist already, or if existing one has no reason + addIfDoesNotExist(results.failures, newFailure, true); } // Parse failed compilation with file and location only (fallback) @@ -186,14 +200,11 @@ function parseHealthcheckOutput(output: string): CompilerResults { column: parseInt(failureWithoutReasonMatch[3], 10), }; + currentFailureWithoutReason = newFailure; + // Only create new failure if it doesn't exist - const key = getUniqueFileKey(newFailure); - if (results.failures.has(key) || suppressedErrorFileKeys.has(key)) { - continue; - } + addIfDoesNotExist(results.failures, newFailure, false); - results.failures.set(key, newFailure); - currentFailureWithoutReason = newFailure; continue; } @@ -202,29 +213,21 @@ function parseHealthcheckOutput(output: string): CompilerResults { if (reasonMatch && currentFailureWithoutReason) { const reason = reasonMatch[1]; - // Only update reason if it's not already set - if (currentFailureWithoutReason.reason) { - currentFailureWithoutReason = null; - continue; - } - const currentFailure: CompilerFailure = { file: currentFailureWithoutReason.file, line: currentFailureWithoutReason.line, column: currentFailureWithoutReason.column, reason, }; - const currentFailureKey = getUniqueFileKey(currentFailure); - if (shouldSuppressCompilerError(reason) || suppressedErrorFileKeys.has(currentFailureKey)) { - currentFailureWithoutReason = null; + currentFailureWithoutReason = null; + + if (shouldSuppressCompilerError(reason)) { + addIfDoesNotExist(results.suppressedFailures, currentFailure, true); continue; } - results.failures.set(currentFailureKey, currentFailure); - - currentFailureWithoutReason = null; - continue; + addIfDoesNotExist(results.failures, currentFailure, true); } } @@ -267,7 +270,11 @@ function createFilesGlob(filesToCheck?: string[]): string | undefined { * @param diffFilteringCommits - The commit range to diff (from and to) * @returns Filtered compiler results containing only failures in changed lines */ -async function filterResultsByDiff(results: CompilerResults, diffFilteringCommits: DiffFilteringCommits, {shouldPrintSuccesses}: PrintResultsOptions): Promise { +async function filterResultsByDiff( + results: CompilerResults, + diffFilteringCommits: DiffFilteringCommits, + {shouldPrintSuccesses, shouldPrintSuppressedErrors}: PrintResultsOptions, +): Promise { // Check for uncommitted changes and warn if any exist if (await Git.hasUncommittedChanges()) { logWarn('Warning: You have uncommitted changes. The diff results may not accurately reflect your current working directory.'); @@ -283,6 +290,7 @@ async function filterResultsByDiff(results: CompilerResults, diffFilteringCommit return { success: new Set(), failures: new Map(), + suppressedFailures: new Map(), }; } @@ -318,6 +326,14 @@ async function filterResultsByDiff(results: CompilerResults, diffFilteringCommit filteredFailures.set(key, failure); }); + const filteredSuppressedFailures = new Map(); + results.suppressedFailures.forEach((failure, key) => { + if (filteredFailures.has(key)) { + return; + } + filteredSuppressedFailures.set(key, failure); + }); + // Filter success set to only include files that are in the diff const changedFiles = new Set(diffResult.files.map((file) => file.filePath)); const filteredSuccesses = new Set(); @@ -336,6 +352,14 @@ async function filterResultsByDiff(results: CompilerResults, diffFilteringCommit } } + if (shouldPrintSuppressedErrors) { + if (filteredSuppressedFailures.size === 0) { + logInfo('No suppressed errors remain after filtering by diff.'); + } else { + logInfo(`${filteredSuppressedFailures.size} out of ${results.suppressedFailures.size} successes remain after filtering by diff.`); + } + } + if (filteredFailures.size === 0) { logInfo('No failures remain after filtering by diff.'); } else { @@ -345,33 +369,62 @@ async function filterResultsByDiff(results: CompilerResults, diffFilteringCommit return { success: filteredSuccesses, failures: filteredFailures, + suppressedFailures: results.suppressedFailures, }; } -function printResults({success, failures}: CompilerResults, {shouldPrintSuccesses}: PrintResultsOptions): void { +function printResults({success, failures, suppressedFailures}: CompilerResults, {shouldPrintSuccesses, shouldPrintSuppressedErrors}: PrintResultsOptions): void { + if (shouldPrintSuccesses && success.size > 0) { + log(); + logSuccess(`Successfully compiled ${success.size} files with React Compiler:`); + log(); + + success.forEach((successFile) => { + logSuccess(`${successFile}`); + }); + + log(); + } + + if (shouldPrintSuppressedErrors && suppressedFailures.size > 0) { + // Create a Map of suppressed error type -> Failure[] with distinct errors and a list of failures with that error + const suppressedErrorMap = new Map(); + suppressedFailures.forEach((failure) => { + if (!failure.reason) { + return; + } + + if (!suppressedErrorMap.has(failure.reason)) { + suppressedErrorMap.set(failure.reason, []); + } + + suppressedErrorMap.get(failure.reason)?.push(failure); + }); + + log(); + logWarn(`Suppressed the following errors in these files:`); + log(); + + for (const [error, suppressedErrorFiles] of suppressedErrorMap.entries()) { + logBold(error); + const filesLine = suppressedErrorFiles.map((failure) => getUniqueFileKey(failure)).join(', '); + logNote(`${TAB} - ${filesLine}`); + } + + log(); + } + const isPassed = failures.size === 0; if (isPassed) { logSuccess('All changed files pass React Compiler compliance check!'); return; } - const tab = ' '; - const distinctFileNames = new Set(); failures.forEach((failure) => { distinctFileNames.add(failure.file); }); - if (shouldPrintSuccesses) { - log(); - logSuccess(`Successfully compiled ${success.size} files with React Compiler:`); - log(); - - success.forEach((successFile) => { - logSuccess(`${successFile}`); - }); - } - log(); logError(`Failed to compile ${distinctFileNames.size} files with React Compiler:`); log(); @@ -379,7 +432,7 @@ function printResults({success, failures}: CompilerResults, {shouldPrintSuccesse failures.forEach((failure) => { const location = failure.line && failure.column ? `:${failure.line}:${failure.column}` : ''; logBold(`${failure.file}${location}`); - logNote(`${tab}${failure.reason ?? 'No reason provided'}`); + logNote(`${TAB}${failure.reason ?? 'No reason provided'}`); }); log(); @@ -472,14 +525,19 @@ async function main() { required: false, default: false, }, + printSuppressedErrors: { + description: 'Print suppressed errors', + required: false, + default: false, + }, }, }); const {command, file} = cli.positionalArgs; const {remote, reportFileName} = cli.namedArgs; - const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff, printSuccesses: shouldPrintSuccesses} = cli.flags; + const {report: shouldGenerateReport, filterByDiff: shouldFilterByDiff, printSuccesses: shouldPrintSuccesses, printSuppressedErrors: shouldPrintSuppressedErrors} = cli.flags; - const commonOptions: BaseCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses}; + const commonOptions: BaseCheckOptions = {shouldGenerateReport, reportFileName, shouldFilterByDiff, shouldPrintSuccesses, shouldPrintSuppressedErrors}; async function runCommand() { switch (command) { From 7fa170915d63a580b5a71b55e0d295357b93e9e6 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 11:46:35 +0100 Subject: [PATCH 69/78] chore: run `npm run gh-actions-build` --- .../javascript/getPullRequestIncrementalChanges/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js index f1c47b5e1ed5..4818c1f327a4 100644 --- a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js +++ b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js @@ -12897,9 +12897,9 @@ const COLOR_BOLD = '\x1b[1m'; const EMOJIS = { // One column emojis need to be rendered with an extra space after to align with two column emojis INFO: '▶️ ', + WARN: '⚠️ ', // Two column emojis can be rendered as-is SUCCESS: '✅', - WARN: '⚠️', ERROR: '🔴', }; const log = (...args) => { From 39ae48e912b87be5e8a95f7cbd43b1410c16b87c Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:35:55 +0100 Subject: [PATCH 70/78] fix: spread object last to override default values --- scripts/utils/Git.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/Git.ts b/scripts/utils/Git.ts index 1b761b8331cf..67812b206387 100644 --- a/scripts/utils/Git.ts +++ b/scripts/utils/Git.ts @@ -9,9 +9,9 @@ import {log, error as logError, warn as logWarn} from './Logger'; type ExecOptions = Omit & {cwd?: ExecWithCallbackOptions['cwd']}; function exec(command: string, options?: ExecOptions) { const optionsWithEncoding = { - ...options, encoding: 'utf8', cwd: process.cwd(), + ...options, }; return promisify(execWithCallback)(command, optionsWithEncoding); From 0d3092efb1d37e4832897e70b4897e1b6c9f83de Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:36:17 +0100 Subject: [PATCH 71/78] fix: return filtered suppressed errors in `filterResultsByDiff` --- scripts/react-compiler-compliance-check.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 9a12ff60cf1e..464dd668dbb6 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -369,7 +369,7 @@ async function filterResultsByDiff( return { success: filteredSuccesses, failures: filteredFailures, - suppressedFailures: results.suppressedFailures, + suppressedFailures: filteredSuppressedFailures, }; } From 5190a12024ab6ad8e7a735508ffc6fc4963879b0 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:46:39 +0100 Subject: [PATCH 72/78] fix: `addFailureIfDoesNotExist` not updating reason if it is not set yet --- scripts/react-compiler-compliance-check.ts | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 464dd668dbb6..ce6205e7baa5 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -135,16 +135,21 @@ function runCompilerHealthcheck(src?: string): CompilerResults { } // eslint-disable-next-line rulesdir/no-negated-variables -function addIfDoesNotExist(failureMap: FailureMap, failure: CompilerFailure, shouldOnlyAddIfNoReason: boolean): boolean { - const key = getUniqueFileKey(failure); - if (failureMap.has(key)) { - if (shouldOnlyAddIfNoReason && failureMap.get(key)?.reason) { - return false; +function addFailureIfDoesNotExist(failureMap: FailureMap, newFailure: CompilerFailure, shouldUpdateReason: boolean): boolean { + const key = getUniqueFileKey(newFailure); + const existingFailure = failureMap.get(key); + + if (existingFailure) { + const isReasonSet = !!existingFailure.reason; + if (shouldUpdateReason && !isReasonSet) { + failureMap.set(key, newFailure); + return true; } + return false; } - failureMap.set(key, failure); + failureMap.set(key, newFailure); return true; } @@ -183,12 +188,12 @@ function parseHealthcheckOutput(output: string): CompilerResults { currentFailureWithoutReason = null; if (shouldSuppressCompilerError(newFailure.reason)) { - addIfDoesNotExist(results.suppressedFailures, newFailure, true); + addFailureIfDoesNotExist(results.suppressedFailures, newFailure, true); continue; } // Only add if failure does not exist already, or if existing one has no reason - addIfDoesNotExist(results.failures, newFailure, true); + addFailureIfDoesNotExist(results.failures, newFailure, true); } // Parse failed compilation with file and location only (fallback) @@ -203,7 +208,7 @@ function parseHealthcheckOutput(output: string): CompilerResults { currentFailureWithoutReason = newFailure; // Only create new failure if it doesn't exist - addIfDoesNotExist(results.failures, newFailure, false); + addFailureIfDoesNotExist(results.failures, newFailure, false); continue; } @@ -223,11 +228,11 @@ function parseHealthcheckOutput(output: string): CompilerResults { currentFailureWithoutReason = null; if (shouldSuppressCompilerError(reason)) { - addIfDoesNotExist(results.suppressedFailures, currentFailure, true); + addFailureIfDoesNotExist(results.suppressedFailures, currentFailure, true); continue; } - addIfDoesNotExist(results.failures, currentFailure, true); + addFailureIfDoesNotExist(results.failures, currentFailure, true); } } From 5f1ba7015b72d6eb6c572570587e3ce64dd1a86a Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:48:28 +0100 Subject: [PATCH 73/78] fix: simplify function --- scripts/react-compiler-compliance-check.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index ce6205e7baa5..701748a21a77 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -135,13 +135,14 @@ function runCompilerHealthcheck(src?: string): CompilerResults { } // eslint-disable-next-line rulesdir/no-negated-variables -function addFailureIfDoesNotExist(failureMap: FailureMap, newFailure: CompilerFailure, shouldUpdateReason: boolean): boolean { +function addFailureIfDoesNotExist(failureMap: FailureMap, newFailure: CompilerFailure): boolean { const key = getUniqueFileKey(newFailure); const existingFailure = failureMap.get(key); if (existingFailure) { const isReasonSet = !!existingFailure.reason; - if (shouldUpdateReason && !isReasonSet) { + const isNewReasonSet = !!newFailure.reason; + if (!isReasonSet && isNewReasonSet) { failureMap.set(key, newFailure); return true; } @@ -188,12 +189,12 @@ function parseHealthcheckOutput(output: string): CompilerResults { currentFailureWithoutReason = null; if (shouldSuppressCompilerError(newFailure.reason)) { - addFailureIfDoesNotExist(results.suppressedFailures, newFailure, true); + addFailureIfDoesNotExist(results.suppressedFailures, newFailure); continue; } // Only add if failure does not exist already, or if existing one has no reason - addFailureIfDoesNotExist(results.failures, newFailure, true); + addFailureIfDoesNotExist(results.failures, newFailure); } // Parse failed compilation with file and location only (fallback) @@ -208,7 +209,7 @@ function parseHealthcheckOutput(output: string): CompilerResults { currentFailureWithoutReason = newFailure; // Only create new failure if it doesn't exist - addFailureIfDoesNotExist(results.failures, newFailure, false); + addFailureIfDoesNotExist(results.failures, newFailure); continue; } @@ -228,11 +229,11 @@ function parseHealthcheckOutput(output: string): CompilerResults { currentFailureWithoutReason = null; if (shouldSuppressCompilerError(reason)) { - addFailureIfDoesNotExist(results.suppressedFailures, currentFailure, true); + addFailureIfDoesNotExist(results.suppressedFailures, currentFailure); continue; } - addFailureIfDoesNotExist(results.failures, currentFailure, true); + addFailureIfDoesNotExist(results.failures, currentFailure); } } From 283fb2a795e962b8a094ea4e4aef57e052546e8b Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:50:28 +0100 Subject: [PATCH 74/78] fix: simplify CLI command execution block --- scripts/react-compiler-compliance-check.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 701748a21a77..2b434bb7baad 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -557,14 +557,12 @@ async function main() { } } - let isPassed = false; try { - isPassed = await runCommand(); + const isPassed = await runCommand(); + process.exit(isPassed ? 0 : 1); } catch (error) { logError('Error running react-compiler-compliance-check:', error); - isPassed = false; - } finally { - process.exit(isPassed ? 0 : 1); + process.exit(1); } } From 5dba074335605bce41c06beb47fb2b41d3e9e59e Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:59:04 +0100 Subject: [PATCH 75/78] refactor: minor simplifications --- scripts/react-compiler-compliance-check.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 2b434bb7baad..6356381d1b91 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -12,7 +12,6 @@ import {join} from 'path'; import type {TupleToUnion} from 'type-fest'; import CLI from './utils/CLI'; import Git from './utils/Git'; -import type {DiffResult} from './utils/Git'; import {log, bold as logBold, error as logError, info as logInfo, note as logNote, success as logSuccess, warn as logWarn} from './utils/Logger'; const TAB = ' '; @@ -88,8 +87,8 @@ async function check({ if (shouldFilterByDiff) { const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); - const headCommitHash = 'HEAD'; - const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: headCommitHash}; + const diffFilteringCommits: DiffFilteringCommits = {from: mainBaseCommitHash, to: 'HEAD'}; + results = await filterResultsByDiff(results, diffFilteringCommits, {shouldPrintSuccesses, shouldPrintSuppressedErrors}); } @@ -125,7 +124,7 @@ function runCompilerHealthcheck(src?: string): CompilerResults { srcString = srcString?.endsWith('"') ? srcString : `${srcString}"`; } - const command = `npx react-compiler-healthcheck ${src ? `--src ${srcString}` : ''} --verbose `; + const command = `npx react-compiler-healthcheck ${src ? `--src ${srcString}` : ''} --verbose`; const output = execSync(command, { encoding: 'utf8', cwd: process.cwd(), @@ -158,9 +157,9 @@ function parseHealthcheckOutput(output: string): CompilerResults { const lines = output.split('\n'); const results: CompilerResults = { - success: new Set(), - failures: new Map(), - suppressedFailures: new Map(), + success: new Set(), + failures: new Map(), + suppressedFailures: new Map(), }; let currentFailureWithoutReason: CompilerFailure | null = null; @@ -289,7 +288,7 @@ async function filterResultsByDiff( logInfo(`Filtering results by diff between ${diffFilteringCommits.from} and ${diffFilteringCommits.to}...`); // Get the diff between the two commits - const diffResult: DiffResult = Git.diff(diffFilteringCommits.from, diffFilteringCommits.to); + const diffResult = Git.diff(diffFilteringCommits.from, diffFilteringCommits.to); // If there are no changes, return empty results if (!diffResult.hasChanges) { @@ -303,9 +302,7 @@ async function filterResultsByDiff( // Create a map of file paths to changed line numbers for quick lookup const changedLinesMap = new Map>(); for (const file of diffResult.files) { - const changedLines = new Set(); - file.addedLines.forEach((line) => changedLines.add(line)); - file.modifiedLines.forEach((line) => changedLines.add(line)); + const changedLines = new Set([...file.addedLines, ...file.modifiedLines]); changedLinesMap.set(file.filePath, changedLines); } @@ -548,7 +545,7 @@ async function main() { async function runCommand() { switch (command) { case 'check': - return Checker.check({filesToCheck: file !== '' ? [file] : undefined, ...commonOptions}); + return Checker.check({files: file ? [file] : undefined, ...commonOptions}); case 'check-changed': return Checker.checkChangedFiles({remote, ...commonOptions}); default: From d966ecc763f64188c725575b8812a1665f9cb2a0 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 20 Oct 2025 23:59:16 +0100 Subject: [PATCH 76/78] refactor: rename property --- scripts/react-compiler-compliance-check.ts | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index 6356381d1b91..dce9ad3207ca 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -64,11 +64,11 @@ type BaseCheckOptions = PrintResultsOptions & { }; type CheckOptions = BaseCheckOptions & { - filesToCheck?: string[]; + files?: string[]; }; async function check({ - filesToCheck, + files, shouldGenerateReport = false, reportFileName = DEFAULT_REPORT_FILENAME, shouldFilterByDiff = false, @@ -76,13 +76,13 @@ async function check({ shouldPrintSuccesses = false, shouldPrintSuppressedErrors = false, }: CheckOptions): Promise { - if (filesToCheck) { - logInfo(`Running React Compiler check for ${filesToCheck.length} files or glob patterns...`); + if (files) { + logInfo(`Running React Compiler check for ${files.length} files or glob patterns...`); } else { logInfo('Running React Compiler check for all files...'); } - const src = createFilesGlob(filesToCheck); + const src = createFilesGlob(files); let results = runCompilerHealthcheck(src); if (shouldFilterByDiff) { @@ -107,14 +107,13 @@ async function checkChangedFiles({remote, ...restOptions}: BaseCheckOptions): Pr const mainBaseCommitHash = await Git.getMainBranchCommitHash(remote); const changedFiles = await Git.getChangedFileNames(mainBaseCommitHash); - const filesToCheck = [...new Set(changedFiles)]; - if (filesToCheck.length === 0) { + if (changedFiles.length === 0) { logSuccess('No React files changed, skipping check.'); return true; } - return check({filesToCheck, ...restOptions}); + return check({files: changedFiles, ...restOptions}); } function runCompilerHealthcheck(src?: string): CompilerResults { @@ -255,16 +254,16 @@ function getUniqueFileKey({file, line, column}: CompilerFailure): string { return file + (isLineSet ? `:${line}` : '') + (isLineAndColumnSet ? `:${column}` : ''); } -function createFilesGlob(filesToCheck?: string[]): string | undefined { - if (!filesToCheck || filesToCheck.length === 0) { +function createFilesGlob(files?: string[]): string | undefined { + if (!files || files.length === 0) { return undefined; } - if (filesToCheck.length === 1) { - return filesToCheck.at(0); + if (files.length === 1) { + return files.at(0); } - return `**/+(${filesToCheck.join('|')})`; + return `**/+(${files.join('|')})`; } /** From e72e8d00d8a3449325ff12a03884dae08ed3bc1b Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 21 Oct 2025 00:01:03 +0100 Subject: [PATCH 77/78] chore: run `npm run gh-actions-build` --- .../javascript/getPullRequestIncrementalChanges/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js index 4818c1f327a4..56301e47dd84 100644 --- a/.github/actions/javascript/getPullRequestIncrementalChanges/index.js +++ b/.github/actions/javascript/getPullRequestIncrementalChanges/index.js @@ -12546,9 +12546,9 @@ const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); const Logger_1 = __nccwpck_require__(8891); function exec(command, options) { const optionsWithEncoding = { - ...options, encoding: 'utf8', cwd: process.cwd(), + ...options, }; return (0, util_1.promisify)(child_process_1.exec)(command, optionsWithEncoding); } From 5d9fd229f93f81cc029a33f8dc59f7837f6b047d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 21 Oct 2025 00:22:00 +0100 Subject: [PATCH 78/78] fix: update final success log message --- scripts/react-compiler-compliance-check.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/react-compiler-compliance-check.ts b/scripts/react-compiler-compliance-check.ts index dce9ad3207ca..b7f150914eb3 100644 --- a/scripts/react-compiler-compliance-check.ts +++ b/scripts/react-compiler-compliance-check.ts @@ -418,7 +418,7 @@ function printResults({success, failures, suppressedFailures}: CompilerResults, const isPassed = failures.size === 0; if (isPassed) { - logSuccess('All changed files pass React Compiler compliance check!'); + logSuccess('All files pass React Compiler compliance check!'); return; }