Skip to content

Conversation

@kazupon
Copy link
Member

@kazupon kazupon commented Nov 12, 2025

Description

Linked Issues

related #69

Additional context

Summary by CodeRabbit

  • New Features
    • Added deprecation warnings to 13 utility functions across localization modules.
    • Warnings emit only once per message to minimize console output.
    • No changes to existing functionality or behavior.

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Walkthrough

The PR introduces a deprecation warning system by creating a new warnOnce utility function in src/utils.ts and applying it to multiple exported functions in both src/h3.ts and src/hono.ts to alert users that these utilities are deprecated and should migrate to @intlify/utils.

Changes

Cohort / File(s) Summary
Deprecation Warning Infrastructure
src/utils.ts
New utility module exporting warnOnce(msg: string) function that emits warnings only once per message. Includes internal warn helper for console logging and hasWarned cache to track emitted messages.
Deprecation Warnings in h3
src/h3.ts
Imports warnOnce and adds deprecation warnings to 13 exported functions: getHeaderLanguages, getHeaderLanguage, getHeaderLocales, tryHeaderLocales, getHeaderLocale, tryHeaderLocale, getCookieLocale, tryCookieLocale, setCookieLocale, getPathLocale, tryPathLocale, getQueryLocale, tryQueryLocale. Core logic unchanged.
Deprecation Warnings in hono
src/hono.ts
Imports warnOnce and adds deprecation warnings to the same 13 exported utility functions as h3.ts. Directs users to use equivalents from @intlify/utils. Core logic unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Verify that all 13 functions in each file (h3.ts and hono.ts) have consistent deprecation warning messages
  • Confirm the warnOnce implementation correctly prevents duplicate warnings across multiple function calls
  • Check that warning messages accurately direct users to the replacement utilities in @intlify/utils

Poem

🐰 Hop along the deprecation path,
With warnings echoing, but just once, not wrath!
Old functions fade as new ones bloom,
A gentle nudge away from gloom.
Intlify utilities await, the signs say clear— 🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title contains a typo ('hone' instead of 'hono') and lacks clarity about the specific change, making it somewhat misleading despite addressing a real part of the changeset. Correct the typo to 'feat!: warning for h3 and hono utils' and consider if the title sufficiently conveys that this introduces deprecation warnings for specific utility functions.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/warning-h3-and-hono-entries

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kazupon kazupon changed the title feat: warning for h3 and hone utils feat!: warning for h3 and hone utils Nov 12, 2025
@kazupon kazupon added breaking Includes backwards-incompatible fixes feature Includes new features labels Nov 12, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 12, 2025

Open in StackBlitz

npm i https://pkg.pr.new/intlify/utils/@intlify/utils@70

commit: b5e3902

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/utils.ts (1)

6-28: LGTM! Clean deprecation warning utility.

The implementation is solid: checking console availability, deduplicating warnings via the hasWarned cache, and providing a simple public API. This is an appropriate pattern for deprecation warnings.

Optional consideration: The hasWarned cache grows unbounded. For deprecation warnings with a fixed set of messages (as in this PR), this is negligible. If the utility were to be used more broadly with dynamic messages, consider adding a cache size limit or TTL, but for the current use case this is perfectly fine.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81c8f1f and b5e3902.

📒 Files selected for processing (3)
  • src/h3.ts (14 hunks)
  • src/hono.ts (14 hunks)
  • src/utils.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/hono.ts (1)
src/utils.ts (1)
  • warnOnce (23-28)
src/h3.ts (1)
src/utils.ts (1)
  • warnOnce (23-28)
🔇 Additional comments (2)
src/hono.ts (1)

28-28: Excellent deprecation strategy.

The deprecation warnings are consistently applied across all Hono utilities, placed at function entry, and provide clear migration guidance to users. The underlying functionality remains unchanged, ensuring backward compatibility while guiding users toward the unified @intlify/utils API.

Also applies to: 61-63, 95-97, 130-132, 151-153, 192-194, 218-220, 255-257, 277-279, 316-318, 336-338, 354-356, 376-378, 395-397

src/h3.ts (1)

28-28: LGTM! Consistent H3 deprecation warnings.

The deprecation approach mirrors src/hono.ts perfectly, maintaining consistency across framework-specific entry points. All warnings are properly placed and provide clear migration paths to the unified API.

Also applies to: 65-67, 103-105, 137-139, 158-160, 199-201, 225-227, 261-263, 283-285, 321-323, 341-343, 359-361, 381-383, 400-402

@kazupon kazupon merged commit 43875f6 into main Nov 12, 2025
9 checks passed
@kazupon kazupon deleted the feat/warning-h3-and-hono-entries branch November 12, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Includes backwards-incompatible fixes feature Includes new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants