Skip to content

fix(json-formatter): singularize sibilant and ambiguous -ses plurals in xml and typescript - #467

Merged
anurag629 merged 2 commits into
codercops:developfrom
bhushan4work:462
Nov 4, 2026
Merged

anurag629 merged 2 commits into
codercops:developfrom
bhushan4work:462

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

what and why

closes #462

fixes incorrect singularization of sibilant plurals and ambiguous -ses endings in the json formatter.

  • handles -ches, -shes, -xes, -zes, and doubled-consonant -zzes plurals.
  • correctly handles ambiguous -ses endings, including cases → case, addresses → address, and statuses → status.
  • preserves existing behavior for categories → category, users → user, boss → bossItem, and root → rootItem.
  • ensures both typescript interfaces and xml element tags use correctly singularized names.

how i tested this

  • vitest: json-utils.test.ts (165/165 tests passed).
  • npm run lint (0 errors).
  • verified regression coverage for singularization and both conversion outputs.

ai assistance

none

type of change

  • bug fix
  • tests
  • new tool or feature
  • refactor or cleanup
  • docs

checklist

  • i was assigned the linked issue
  • npm run lint && npm run test && npm run build passes locally
  • logic changes live in lib/ and have a test in lib/__tests__/
  • for a bug fix: the new test fails without my change
  • no analytics, trackers, or calls that send user data off-device
  • works in both light and dark themes (if ui changed)
  • inputs have labels and it works with the keyboard alone (if ui changed)
  • new tool: registry entry, page.tsx, client component, opengraph-image.tsx, and the bug report dropdown are all done

notes for reviewers

none

…in XML and TypeScript (codercops#462)

singularize() handled -ies and generic -ses but mis-singularized
sibilant plurals (matches → matche, boxes → boxe, quizzes → quizz)
and ambiguous -ses words (cases → cas). Add rules for -ches, -shes,
-xes, -zes and doubled-consonant -zzes, and make the -ses case strip
"es" only when the stem is long enough to be a real singular ending
in s (addresses → address, statuses → status), otherwise strip just
"s" (cases → case). Preserves categories → category, users → user,
boss → bossItem, root → rootItem.

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @bhushan4work, nice, matches, boxes, hashes, quizzes and cases come out right now. I ran a bunch of common keys through toXML on this branch and on develop, though, and a few got worse:

  • -zes: sizes, prizes and mazes become siz, priz and maz, where develop gives size, prize and maze. Only -zzes needs the es dropped, so I'd keep just that rule.
  • buses becomes buse (develop gives bus).
  • A long -ses stem still loses too much: responses, courses, releases, licenses and databases give respons, cours, releas, licens and databas. The stem's ending works better than its length here: drop es when the stem ends in ss (addresses, classes) or in tus, rus, nus, pus or bus (statuses, viruses, bonuses, campuses, buses), and only the s otherwise (cases, causes, houses, responses, courses).

caches turning into cach is fine by me, since words like matches and branches are far more common. Please add these words to the tests too.

…es plurals (codercops#462)

- Only strip "es" on -zzes (e.g. quizzes -> quiz), keeping sizes -> size, prizes -> prize, mazes -> maze intact
- For ambiguous -ses, remove "es" only when the resulting stem ends in ss, tus, rus, nus, pus, or bus; otherwise strip only trailing "s"
- Keep -ches, -shes, and -xes rules (caches -> cach)
- Add regression tests covering direct singularize(), toXML(), and toTypeScript() conversions
@anurag629 anurag629 added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 4, 2026
@anurag629
anurag629 merged commit aa31a81 into codercops:develop Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

singularize() leaves a trailing e for -es plurals ending in ch, sh, x, and z (matches → Matche, boxes → Boxe)

2 participants