@samitouri / QOS-React-1 / commits / 7aca04a0d6

[babel] Refactor handleError to pass the error first

Pass the most important and required argument as the first parameter.

Sathya Gunasekaran committed Nov 8, 2023 at 16:09 UTC 7aca04a0d677f2a4adcaff18c951992016f4605b
1 file changed +6 -6
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+6 -6
@@ -66,9 +66,9 @@ type CompileResult = {
66 };
67
68 function handleError(
69 + err: CompilerError,
70 pass: CompilerPass,
70 - fnLoc: t.SourceLocation | null,
71 - err: CompilerError
71 + fnLoc: t.SourceLocation | null
72 ): void {
73 if (pass.opts.logger) {
74 for (const detail of err.details) {
@@ -237,7 +237,7 @@ export function compileProgram(
237 * Report lint suppressions as InvalidReact if we find forget-able
238 * functions within the file
239 */
240 - handleError(pass, fn.node.loc ?? null, lintError);
240 + handleError(lintError, pass, fn.node.loc ?? null);
241 }
242
243 let compiledFn: CodegenFunction;
@@ -256,7 +256,7 @@ export function compileProgram(
256 });
257 } catch (err) {
258 hasCriticalError ||= isCriticalError(err);
259 - handleError(pass, fn.node.loc ?? null, err);
259 + handleError(err, pass, fn.node.loc ?? null);
260 return;
261 }
262
@@ -305,7 +305,7 @@ export function compileProgram(
305 compiledFns.map(({ originalFn }) => originalFn)
306 );
307 if (error) {
308 - handleError(pass, null, error);
308 + handleError(error, pass, null);
309 return;
310 }
311 }
@@ -332,7 +332,7 @@ export function compileProgram(
332 externalFunctions.push(enableEmitFreeze);
333 }
334 } catch (err) {
335 - handleError(pass, null, err);
335 + handleError(err, pass, null);
336 return;
337 }
338