From 7aca04a0d677f2a4adcaff18c951992016f4605b Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Wed, 8 Nov 2023 16:09:19 +0000 Subject: [PATCH] [babel] Refactor handleError to pass the error first Pass the most important and required argument as the first parameter. --- .../src/Entrypoint/Program.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index ac03d0183d..2b66d10576 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -66,9 +66,9 @@ type CompileResult = { }; function handleError( + err: CompilerError, pass: CompilerPass, - fnLoc: t.SourceLocation | null, - err: CompilerError + fnLoc: t.SourceLocation | null ): void { if (pass.opts.logger) { for (const detail of err.details) { @@ -237,7 +237,7 @@ export function compileProgram( * Report lint suppressions as InvalidReact if we find forget-able * functions within the file */ - handleError(pass, fn.node.loc ?? null, lintError); + handleError(lintError, pass, fn.node.loc ?? null); } let compiledFn: CodegenFunction; @@ -256,7 +256,7 @@ export function compileProgram( }); } catch (err) { hasCriticalError ||= isCriticalError(err); - handleError(pass, fn.node.loc ?? null, err); + handleError(err, pass, fn.node.loc ?? null); return; } @@ -305,7 +305,7 @@ export function compileProgram( compiledFns.map(({ originalFn }) => originalFn) ); if (error) { - handleError(pass, null, error); + handleError(error, pass, null); return; } } @@ -332,7 +332,7 @@ export function compileProgram( externalFunctions.push(enableEmitFreeze); } } catch (err) { - handleError(pass, null, err); + handleError(err, pass, null); return; }