Skip to content

Commit 180b3ef

Browse files
authored
Merge pull request Expensify#88172 from Expensify/Rory-ImproveReactCompilerErrorFormatting
[No QA] Improve error formatting in React Compiler check script
2 parents d3831cc + ceed278 commit 180b3ef

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

.github/actions/javascript/getPullRequestIncrementalChanges/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12869,7 +12869,7 @@ exports["default"] = Git;
1286912869
"use strict";
1287012870

1287112871
Object.defineProperty(exports, "__esModule", ({ value: true }));
12872-
exports.bold = exports.formatLink = exports.success = exports.error = exports.note = exports.warn = exports.info = exports.log = void 0;
12872+
exports.bold = exports.formatLink = exports.success = exports.errorDetail = exports.error = exports.note = exports.warn = exports.info = exports.log = void 0;
1287312873
const COLOR_DIM = '\x1b[2m';
1287412874
const COLOR_RESET = '\x1b[0m';
1287512875
const COLOR_YELLOW = '\x1b[33m';
@@ -12918,6 +12918,11 @@ const error = (...args) => {
1291812918
log(...lines);
1291912919
};
1292012920
exports.error = error;
12921+
const errorDetail = (...args) => {
12922+
const lines = [` ${COLOR_RED}↳`, ...args, COLOR_RESET];
12923+
log(...lines);
12924+
};
12925+
exports.errorDetail = errorDetail;
1292112926
const formatLink = (name, url) => `\x1b]8;;${url}\x1b\\${name}\x1b]8;;\x1b\\`;
1292212927
exports.formatLink = formatLink;
1292312928

scripts/react-compiler-compliance-check.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import path from 'path';
1515
import CLI from './utils/CLI';
1616
import FileUtils from './utils/FileUtils';
1717
import Git from './utils/Git';
18-
import {log, error as logError, info as logInfo, success as logSuccess, warn as logWarn} from './utils/Logger';
18+
import {log, error as logError, errorDetail as logErrorDetail, info as logInfo, success as logSuccess, warn as logWarn} from './utils/Logger';
1919

2020
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
2121
const ReactCompilerConfig = require('../config/babel/reactCompilerConfig');
@@ -131,7 +131,7 @@ function printErrors(filename: string, errors: CompilerError[]): void {
131131
}
132132
for (const error of errors) {
133133
const location = formatErrorLocation(filename, error);
134-
logError(` ${location}: ${error.reason}`);
134+
logErrorDetail(`${location}: ${error.reason}`);
135135
}
136136
if (IS_CI) {
137137
console.log('::endgroup::');
@@ -157,10 +157,10 @@ function checkFiles(inputs: string[], verbose: boolean): boolean {
157157

158158
switch (result.status) {
159159
case 'compiled':
160-
logSuccess(`COMPILED ${file}`);
160+
logSuccess(`COMPILED ${file}`);
161161
break;
162162
case 'failed':
163-
logError(`FAILED ${file}`);
163+
logError(`FAILED ${file}`);
164164
printErrors(file, result.errors);
165165
hasFailure = true;
166166
break;
@@ -230,7 +230,7 @@ async function checkChangedFiles(remote: string, verbose: boolean): Promise<bool
230230

231231
if (mainStatus === 'compiled') {
232232
failures.push({file: filename, reason: 'File compiled on main but fails to compile on this branch (regression)', errors: result.errors});
233-
logError(`FAILED ${filename} (regression: compiled on main)`);
233+
logError(`FAILED ${filename} (regression: compiled on main)`);
234234
printErrors(filename, result.errors);
235235
} else if (verbose) {
236236
logWarn(`WARNING ${filename} (fails to compile, but also failed on main)`);

scripts/utils/Logger.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const error = (...args: unknown[]) => {
4949
log(...lines);
5050
};
5151

52+
const errorDetail = (...args: unknown[]) => {
53+
const lines = [` ${COLOR_RED}↳`, ...args, COLOR_RESET];
54+
log(...lines);
55+
};
56+
5257
const formatLink = (name: string | number, url: string) => `\x1b]8;;${url}\x1b\\${name}\x1b]8;;\x1b\\`;
5358

54-
export {log, info, warn, note, error, success, formatLink, bold};
59+
export {log, info, warn, note, error, errorDetail, success, formatLink, bold};

0 commit comments

Comments
 (0)