vercel-labs / vercel-labs/konsistent

Use one word-boundary algorithm for placeholder segments

Open
#70 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
176
Forks
6
Avg merge
20h 26m
Merged PRs (30d)
11

Description

Placeholder segment behavior is inconsistent: case conversion and segments(n) split some camel-case, hyphen, and underscore boundaries, while toNthSegment splits only on hyphens, and spaces are not handled consistently. Any word boundary in a name should mean the same thing everywhere, including spaces, hyphens, underscores, and uppercase transitions in camelCase or PascalCase names.

Relevant files:

  • packages/konsistent/src/core/case-utils.ts
  • packages/konsistent/src/core/placeholder.ts
  • packages/konsistent/src/core/constraints/segments.ts
  • packages/konsistent/src/config/schema.ts
  • packages/konsistent/src/config/cli-placeholders.ts

Implement one canonical word-splitting function and use it for segment constraints, nth-segment transforms, and case transforms. Update placeholder value validation where necessary so supported inputs can contain every documented boundary form, with shared tests covering all boundary types.

Backward compatibility: internal helpers and documentation can be renamed or replaced without compatibility shims. If accepted placeholder values or any konsistent.json behavior changes, keep the old behavior available as deprecated where it can be selected explicitly and emit a non-failing CLI warning for deprecated usage.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing boundary handling across packages/konsistent/src/core/case-utils.ts, placeholder.ts, and constraints/segments.ts, then inspect validation and CLI behavior in config/schema.ts and config/cli-placeholders.ts. Add shared tests for spaces, hyphens, underscores, camelCase, and PascalCase, and verify deprecated behavior remains selectable with a non-failing warning where required.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.