fix: make numberFormat always return a string - #858
Conversation
|
Warning Review limit reached
Next review available in: 30 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #855
numberFormathad an inconsistent return type (false | number | string), and its results are interpolated directly into user-facing strings (order descriptions, order titles, trading volume). Nothing breaks today because every caller validates the currency first, but that invariant was implicit — the first future caller that skips thegetCurrencycheck would publish a title like "Selling false sats" to the order channel.Changes
numberFormatnow has an explicit: stringreturn type and falls back toString(number)in every non-formattable case (invalid ISO-4217 code, unknown currency, missing locale, NaN).tests/util/index.spec.tsto the new contract (TDD: tests updated first and confirmed failing, then the fix), including a new case asserting the return is always a string.All 19 existing call sites (
bot/ordersActions.ts,bot/messages.ts) already treat the result as display text; none compares againstfalse, so no behavior changes for valid inputs.Re: the suggestion to enable
@typescript-eslint/explicit-function-return-type— measured it: 381 warnings repo-wide today, so it's a separate effort; this PR adds the explicit return type to the function at hand. Follow-up discussion in #855.Test plan
npm run lintcleannpx tscfull build clean