Skip to main content
rule CX Codex

js-hoist-intl — Claude Code rule for Intl formatters

js-hoist-intl is a Claude Code rule that moves Intl formatter creation out of renders and loops. It applies to JavaScript code that formats dates, numbers, or relative time.

AGPL-3.0 ★ 88 updated 2026-11-17

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/js-hoist-intl.md
Open on GitHub

What js-hoist-intl does

The rule recommends declaring Intl.DateTimeFormat, Intl.NumberFormat, and Intl.RelativeTimeFormat at module scope when their locale and options stay fixed. Render functions can then reuse the formatter instead of constructing one on each call.

For a changing locale, the rule suggests memoizing the formatter and updating it when the locale changes. If the locale can change but the memoized value does not track it, formatting can use stale locale settings.

What it helps with

  • move formatter creation out of a render function
  • avoid constructing a formatter inside a loop
  • memoize a formatter when the locale changes

Example prompts for the agent

  • Refactor this component so it reuses a formatter instead of creating one during render.
  • Check this loop and move Intl.NumberFormat construction outside it.
  • Add date formatting for a changing locale and memoize the formatter.

How to install js-hoist-intl

Manually: put the files in place

.claude/rules/js-hoist-intl.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about js-hoist-intl

How do I install js-hoist-intl in Claude Code?

Add the rule file to the project at .claude/rules/js-hoist-intl.md.

What does js-hoist-intl do?

It recommends moving Intl formatter construction out of renders and loops when locale and options are fixed. For a changing locale, it suggests memoization.

How should js-hoist-intl handle a dynamic locale?

Memoize the formatter and update it when the locale changes.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set47

The whole set →
ui-pressable ui-pressable is a Claude Code rule for choosing touch components in React Native. It applies when an agent adds or edits buttons and list items. CX Codex +1 ★ 88repo stars ui-safe-area-scroll ui-safe-area-scroll is a Claude Code rule that enforces native iOS safe area handling in React Native ScrollViews. It stops layout jumping during keyboard transitions. CX Codex +1 ★ 88repo stars design-system-compound-components design-system-compound-components is a Claude Code rule that forbids raw string children in non-text components. It enforces compound structures like ButtonText and ButtonIcon across the design system. CX Codex +1 ★ 88repo stars ui-expo-image ui-expo-image is a Claude Code rule that swaps React Native's default Image for expo-image. It guides code generation toward blurhash placeholders, disk caching, and list recycling. CX Codex +1 ★ 88repo stars react-state-fallback react-state-fallback is a Claude Code rule that enforces reactive fallbacks instead of copying props into component state. It prevents stale UI bugs during parent updates. CX Codex +1 ★ 88repo stars list-performance-virtualize list-performance-virtualize is a Claude Code rule that recommends virtualized lists for scrollable content. It applies while building list-based screens. CX Codex +1 ★ 88repo stars react-state-minimize react-state-minimize is a Claude Code rule that enforces minimal React state. It directs assistants to compute values on render rather than storing redundant state variables. CX Codex +1 ★ 88repo stars rendering-no-falsy-and rendering-no-falsy-and is a Claude Code rule that guards against unsafe conditional JSX rendering. It targets cases where a value may be an empty string or zero. CX Codex +1 ★ 88repo stars

Project sponsors

Companies that keep this analytics open