hoist-intl
new Intl.NumberFormat(...) with constant arguments inside a function or loop, and localeCompare with a locale inside a sort comparator.
Why: creating an Intl formatter or collator loads locale data and is expensive; using one is cheap (v8.dev). Build it once and reuse it.
✕ Rejectedhoist-intl
ts
export function price(cents: number): string {
return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(cents / 100);
}✓ Accepted0 diagnostics
ts
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" });
export function price(cents: number): string {
return usd.format(cents / 100);
}Quick fix: Create it once, at module level: moves the constructor to a module-level const (allowed by no-mutable-global: it is never changed). A locale that comes from data can't be hoisted. Create the formatters once at startup, one per supported locale, and pass them to the code that formats (State); a module-level Map filled on demand would be no-mutable-global. A locale from data can also be invalid, so new Intl.NumberFormat(locale) is unhandled-failure until you wrap it in unsafe(...).