feat(aliases): colonial-era, spelling & ASCII country name aliases - #179
Conversation
Extends getCountryCode name resolution with a curated historical set: - Colonial / independence-era former names (Rhodesia, Abyssinia, Dahomey, Upper Volta, Gold Coast, Nyasaland, Formosa, New Hebrides, ...). - Common spelling / transliteration variants (Byelorussia, Moldavia, Rumania, Bahrein, Kirghizia, Turkmenia, ...). - Diacritic-free forms where the name/native carries diacritics (Cote d'Ivoire, Turkiye). 35 aliases across 31 countries, ~0.5 KB. All collision-checked by the existing guard test — no name, native, or alias resolves to two countries. Refs #35
📝 WalkthroughWalkthroughUpdated country data with historical aliases and spelling variants for multiple ISO2 entries, including expanded Türkiye and United States alias lists. Added tests verifying that names such as “Rhodesia,” “Abyssinia,” “Gold Coast,” “Formosa,” and “Rumania” resolve to the expected country codes. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Extends getCountryCode(name) backward-compatible name resolution by adding curated colonial-era, spelling/transliteration, and ASCII/diacritic-free country name aliases, plus a small regression-style test to exercise a representative subset.
Changes:
- Added new
aliasentries for additional historical/spelling/ASCII variants in the countries dataset. - Expanded JS test coverage with a new test for several of the newly supported aliases.
- Kept the existing guard tests ensuring aliases remain unambiguous and resolve to the owning country.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/test-js/getCountryCode.aliases.test.ts | Adds a test covering several new colonial-era/spelling/ASCII alias resolutions. |
| packages/countries/src/data/countries.ts | Adds curated alias strings to multiple countries to expand getCountryCode name matching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/test-js/getCountryCode.aliases.test.ts (1)
22-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover all newly added aliases, or verify existing coverage.
This test validates 7 of the 35 added aliases. A table-driven test covering each new alias would catch data-entry errors in the remaining entries; otherwise, confirm that the other aliases are covered elsewhere.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/test-js/getCountryCode.aliases.test.ts` around lines 22 - 30, Expand the getCountryCode() alias coverage in the test 'getCountryCode() resolves colonial-era names and spelling variants' to validate every newly added alias, preferably using a table-driven set of alias-to-country expectations; if remaining aliases are already tested elsewhere, verify and preserve that coverage instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/countries/src/data/countries.ts`:
- Line 417: Use consistently single-quoted literals for the Cote d'Ivoire alias
in packages/countries/src/data/countries.ts:417-417 and
packages/test-js/getCountryCode.aliases.test.ts:29-29, escaping the apostrophe
in each occurrence.
---
Nitpick comments:
In `@packages/test-js/getCountryCode.aliases.test.ts`:
- Around line 22-30: Expand the getCountryCode() alias coverage in the test
'getCountryCode() resolves colonial-era names and spelling variants' to validate
every newly added alias, preferably using a table-driven set of alias-to-country
expectations; if remaining aliases are already tested elsewhere, verify and
preserve that coverage instead.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a903ac2-7033-4c8d-b837-9026470a4437
📒 Files selected for processing (2)
packages/countries/src/data/countries.tspackages/test-js/getCountryCode.aliases.test.ts
Companion to 'USA'/'America' — 'US' is the most common short form and was the one gap in issue #35's short-form list. Collision-free.
Follow-up to #178, also for 3.4.1. Extends
getCountryCodename resolution beyond the recent-ISO-rename backward-compat set (which #178 covered) into curated historical and alternate names.What's added — 36 aliases across 31 countries (~0.5 KB)
Cote d'Ivoire→CI,Turkiye→TR.US→US — companion to the existingUSA/America; the one short-form gap from Add alternative country names #35.Each maps unambiguously to one current country — deliberately excludes ambiguous bare forms (no "Congo", no "Korea").
Why these / not more
Safety & size
countries.min.jsongrows ~0.5 KB. Non-breaking.Verified
bun run cigreen — lint, 3 typecheck targets, build, 22 tests. No generateddist/committed (rebuilt at release).Refs #35.