# js-hoist-intl

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.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 88 repo stars
- Author: alexj11324
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/alexj11324/Mikka/tree/HEAD/.claude/skills/react-native-skills/rules/js-hoist-intl.md
- Updated: 2026-11-17
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/js-hoist-intl

## What it 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.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/js-hoist-intl.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/js-hoist-intl.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/js-hoist-intl.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/js-hoist-intl.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/js-hoist-intl.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/alexj11324/Mikka/tree/HEAD/.claude/skills/react-native-skills/rules/js-hoist-intl.md

## When to use it
- move formatter creation out of a render function
- avoid constructing a formatter inside a loop
- memoize a formatter when the locale changes

## Example prompts
- 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.

## Similar
- [js-hoist-regexp](https://affpapa.org/en/nevibecode/rules/js-hoist-regexp.md) — rule · ★ 7191 repo stars
- [ultracite](https://affpapa.org/en/nevibecode/skills/ultracite.md) — skill · 13600 installs
- [next-intl-app-router](https://affpapa.org/en/nevibecode/skills/next-intl-app-router.md) — skill · 619 installs
- [internationalization-i18n](https://affpapa.org/en/nevibecode/skills/secondsky-internationalization-i18n.md) — skill · 464 installs
- [i18n-localization](https://affpapa.org/en/nevibecode/skills/travisjneuman-i18n-localization.md) — skill · 143 installs
- [next-intl-add-language](https://affpapa.org/en/nevibecode/skills/next-intl-add-language.md) — skill · 9349 installs

From the same set: [alexj11324/mikka](https://affpapa.org/en/nevibecode/by/alexj11324/mikka.md) — 47 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
