From 87c03a0a134b19ffbda6bbef4b12202f4f5a4347 Mon Sep 17 00:00:00 2001 From: David Michael Gregg Date: Fri, 31 Jan 2025 01:44:02 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20typo=20in=20dangerfile.js=20which=20resul?= =?UTF-8?q?ts=20in=20an=20unreachable=20code=20path=E2=80=A6=20(#32277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fix typo in dangerfile.js which results in an unreachable code path which ought to be hit when there is no matching base artifact during DangerCI automated code review. See: https://github.com/facebook/react/blob/221f3002caa2314cba0a62950da6fb92b453d1d0/dangerfile.js#L73 Compare: https://github.com/facebook/react/blob/221f3002caa2314cba0a62950da6fb92b453d1d0/dangerfile.js#L171 And the case which should hit this code path: https://github.com/facebook/react/blob/221f3002caa2314cba0a62950da6fb92b453d1d0/dangerfile.js#L160 Given the above context, the condition `Number === Infinity` is clearly meant to be `decimal === Infinity`, which it will be if the `catch` statement triggers when there is no matching base artifact. Without this fix, the primitive value `Infinity` is passed to `percentFormatter.format(decimal)`, resulting in the string `'+∞%'`. With this fix, the resulting string will be the intended `'New file'`. ## [Resolves issue 32278](https://github.com/facebook/react/issues/32278) --- dangerfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dangerfile.js b/dangerfile.js index bfc41312e4..d60da35b58 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -70,7 +70,7 @@ const percentFormatter = new Intl.NumberFormat('en', { }); function change(decimal) { - if (Number === Infinity) { + if (decimal === Infinity) { return 'New file'; } if (decimal === -1) {