Skip to content

feat: unify casing libraries — komoji as origin of truth#74

Merged
pyramation merged 2 commits intomainfrom
devin/1774610281-unify-casing-libs
Mar 27, 2026
Merged

feat: unify casing libraries — komoji as origin of truth#74
pyramation merged 2 commits intomainfrom
devin/1774610281-unify-casing-libs

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Mar 27, 2026

Summary

Makes komoji the single origin for all pure case transformations and has inflekt delegate to it, eliminating duplicate implementations.

komoji changes:

  • Bugfix: toPascalCase now handles consecutive separators correctly ("my__double_under""MyDoubleUnder" instead of "MydoubleUnder")
  • New exports: lcFirst and ucFirst (moved from inflekt)
  • New tests for the bug fix, new functions, and edge cases (spaces, leading separators, consecutive mixed separators)

inflekt changes:

  • lcFirst, ucFirst, toPascalCase, toCamelCase now delegate to komoji
  • toSnakeCase and toConstantCase are re-exported directly from komoji (new exports — lets consumers adopt the preferred names without adding komoji as a direct dependency)
  • underscore delegates to komoji's toSnakeCase (marked @deprecated)
  • toScreamingSnake delegates to komoji's toConstantCase (marked @deprecated)
  • fixCapitalisedPlural remains in inflekt (inflekt-specific)
  • Added komoji as a workspace dependency

All 60 komoji tests and 88 inflekt tests pass.

Review & Testing Checklist for Human

  • Acronym handling change in underscore / toScreamingSnake: The old inflekt underscore split every uppercase letter individually ("APIKey""a_p_i_key"). Komoji's toSnakeCase groups acronyms ("APIKey""api_key"). This is arguably better but is a silent behavioral change for downstream callers passing acronym-heavy strings. Grep for underscore( and toScreamingSnake( usage across all consumers and verify the new acronym behavior is acceptable.
  • toCamelCase now handles spaces: Old inflekt only handled - and _ delimiters. Komoji also handles spaces and consecutive separators. Verify no downstream code relies on spaces being preserved.
  • toPascalCase broadened scope: Same as above — now handles spaces and consecutive separators. Verify downstream behavior.
  • Confirm workspace:* resolves correctly at publish time: When inflekt is published to npm, komoji must be published first (or simultaneously) so the workspace protocol resolves to a real version.

Recommended test plan: Run the constructive monorepo's full test suite (especially graphql/codegen, graphql/query, pgpm/export) with these updated packages to verify no downstream breakage from the behavioral differences listed above.

Notes

  • The pnpm-lock.yaml diff is large but is almost entirely formatting changes (single quotes vs double quotes from pnpm version). The only meaningful change is the addition of the komoji workspace dependency for inflekt.
  • A companion PR for constructive-io/constructive (#913) migrates toScreamingSnaketoConstantCase and underscoretoSnakeCase imports in consumer code.

Link to Devin session: https://app.devin.ai/sessions/c92c3a11450342f8875625a60fa1be28
Requested by: @pyramation

- Fix toPascalCase bug: consecutive separators (e.g. 'my__double_under')
  now correctly produce 'MyDoubleUnder' instead of 'MydoubleUnder'
- Add ucFirst and lcFirst to komoji
- Update inflekt to re-export case transforms from komoji
- Add komoji as workspace dependency of inflekt
- Mark underscore (use toSnakeCase) and toScreamingSnake (use toConstantCase) as deprecated
- Keep inflekt-specific functions: fixCapitalisedPlural, pluralization, matching, naming
- All 60 komoji tests and 88 inflekt tests pass with no behavioral changes
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Allows consumers to import the preferred API names directly from inflekt
during the migration period.
@pyramation pyramation merged commit 046acbc into main Mar 27, 2026
36 checks passed
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.

1 participant