Skip to content

Commit

Permalink
Fix typo in dangerfile.js which results in an unreachable code path… (#…
Browse files Browse the repository at this point in the history
…32277)

## 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](#32278)
  • Loading branch information
davegregg authored Jan 31, 2025
1 parent 221f300 commit 87c03a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 87c03a0

Please sign in to comment.