Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Formats user-facing numbers in TSX files using formatNumber from @tryghost/shade/utils, replacing toLocaleString and Intl.NumberFormat.
14% 91%+77 ptsof test cases passed
Passed 20 of 22 test cases with the skill, and 3 of 22 without it.
3 of 3 safety checks passed
Not used yet
When editing .tsx files, ensure all user-facing numbers are formatted using the formatNumber utility from @tryghost/shade/utils.
import { formatNumber } from '@tryghost/shade/utils';
Use formatNumber() when rendering any numeric value that is displayed to the user, including:
centsToDollars() for monetary values)<span>{formatNumber(totalMembers)}</span>
<span>{formatNumber(link.count || 0)}</span>
<span>{`${currencySymbol}${formatNumber(centsToDollars(mrr))}`}</span>
<span>{post.members > 0 ? `+${formatNumber(post.members)}` : '0'}</span>
Do NOT use any of these patterns for formatting numbers in TSX files:
// BAD: raw .toLocaleString()
<span>{count.toLocaleString()}</span>
// BAD: manual Intl.NumberFormat
<span>{new Intl.NumberFormat('en-US').format(count)}</span>
Next to this one in the catalogue, plus more from the same author.