Summary
frontend/src/modules/savings-history.ts:332 defines a private formatCurrency(value) that shadows the shared formatCurrency exported from frontend/src/utils.ts (imported and used elsewhere in the same codebase, including in savings-history.ts's siblings via dashboard.ts).
// frontend/src/modules/savings-history.ts:332
function formatCurrency(value: number | null | undefined): string {
if (value == null || !Number.isFinite(value)) {
return '--';
}
if (value >= 1000) {
return `$${(value / 1000).toFixed(2)}K`;
}
return `$${value.toFixed(2)}`;
}
Why this is worth tracking
Found during review of PR LeanerCloud/cloud-commitments-cli#1732 (locale-pinning formatCurrency/getDateParts in utils.ts, issue LeanerCloud/cloud-commitments-cli#1728). This local copy is out of scope for that PR — it uses toFixed(), not toLocaleString(), so it isn't locale-dependent and isn't part of the LeanerCloud/cloud-commitments-cli#1728 bug. But it is a second, independently-maintained "format currency for charts" helper with different behavior (K-abbreviation above $1000) living under the same name as the shared helper. That's a duplication / naming-collision risk:
- A future edit to the shared
formatCurrency (e.g. another locale/format fix) won't propagate here, and nothing signals that this file has its own copy.
- The identical name makes it easy for a future contributor to assume
savings-history.ts uses the shared helper when it doesn't.
Suggested fix
Rename the local helper to something that doesn't collide with the shared name (e.g. formatChartCurrency or formatAbbreviatedCurrency), or evaluate whether the K-abbreviation behavior belongs as an option on the shared formatCurrency in utils.ts instead of a separate copy. Low risk, mechanical rename either way.
Scope
Frontend only, frontend/src/modules/savings-history.ts. No behavior change required — this is a naming/duplication cleanup, not a bug fix.
Summary
frontend/src/modules/savings-history.ts:332defines a privateformatCurrency(value)that shadows the sharedformatCurrencyexported fromfrontend/src/utils.ts(imported and used elsewhere in the same codebase, including insavings-history.ts's siblings viadashboard.ts).Why this is worth tracking
Found during review of PR LeanerCloud/cloud-commitments-cli#1732 (locale-pinning
formatCurrency/getDatePartsinutils.ts, issue LeanerCloud/cloud-commitments-cli#1728). This local copy is out of scope for that PR — it usestoFixed(), nottoLocaleString(), so it isn't locale-dependent and isn't part of the LeanerCloud/cloud-commitments-cli#1728 bug. But it is a second, independently-maintained "format currency for charts" helper with different behavior (K-abbreviation above $1000) living under the same name as the shared helper. That's a duplication / naming-collision risk:formatCurrency(e.g. another locale/format fix) won't propagate here, and nothing signals that this file has its own copy.savings-history.tsuses the shared helper when it doesn't.Suggested fix
Rename the local helper to something that doesn't collide with the shared name (e.g.
formatChartCurrencyorformatAbbreviatedCurrency), or evaluate whether the K-abbreviation behavior belongs as an option on the sharedformatCurrencyinutils.tsinstead of a separate copy. Low risk, mechanical rename either way.Scope
Frontend only,
frontend/src/modules/savings-history.ts. No behavior change required — this is a naming/duplication cleanup, not a bug fix.