Skip to content

fix(@formatjs/cli): extract formatMessage from any object, not just intl#6251

Merged
longlho merged 1 commit intomainfrom
fix-formatmessage-any-object
Apr 10, 2026
Merged

fix(@formatjs/cli): extract formatMessage from any object, not just intl#6251
longlho merged 1 commit intomainfrom
fix-formatmessage-any-object

Conversation

@longlho
Copy link
Copy Markdown
Member

@longlho longlho commented Apr 10, 2026

Summary

  • The Rust CLI only extracted formatMessage() calls when the object was literally named intl or ended with .intl
  • This missed patterns like this.intl.formatMessage(), someVar.formatMessage(), foo.bar.baz.formatMessage()
  • The JS CLI (ts-transformer) has no such restriction — it extracts from any something.formatMessage() call
  • Aligned the Rust CLI behavior to match

Changes

  • Simplified extract_function_name_from_member() to return the property name directly
  • Removed unused is_intl_object() and is_intl_object_from_chain() methods
  • Added conformance test 21_formatmessage_any_object.txt covering this.intl, someVar, this.props.intl, and deep chains

Fixes #6249

Test plan

  • bazel test //crates/formatjs_cli:formatjs_cli_test passes
  • bazel test //packages/cli/integration-tests:conformance_test passes (21/21 test cases)

🤖 Generated with Claude Code

The Rust CLI only extracted formatMessage() calls when the object was
literally named `intl` or ended with `.intl`. This missed patterns like
`this.intl.formatMessage()`, `someVar.formatMessage()`, etc.

The JS CLI (ts-transformer) has no such restriction — it extracts from
any `something.formatMessage()` call. Align the Rust CLI behavior.

Fixes #6249

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@longlho longlho force-pushed the fix-formatmessage-any-object branch from 1e5c895 to 25889ea Compare April 10, 2026 02:30
@longlho longlho enabled auto-merge (squash) April 10, 2026 02:30
@longlho longlho merged commit 7466a97 into main Apr 10, 2026
6 checks passed
@longlho longlho deleted the fix-formatmessage-any-object branch April 10, 2026 02:33
longlho added a commit that referenced this pull request Apr 12, 2026
Patch release for fix in #6251: extract formatMessage from any object,
not just intl.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
trunk-io Bot pushed a commit that referenced this pull request Apr 12, 2026
## Summary
Patch version bump for `formatjs_cli` crate: 1.1.0 → 1.1.1

### Changes since v1.1.0
- #6251: fix(@formatjs/cli): extract formatMessage from any object, not
just intl

## Test plan
- [x] Pre-commit hooks pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust CLI - forced naming convention

1 participant