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
.claude/rules/js-hoist-intl.mdWhat 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.NumberFormatconstruction 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.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/js-hoist-intl.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/js-hoist-intl.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/js-hoist-intl.mdManually: put the files in place
.clinerules/js-hoist-intl.mdStep 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.