Repository navigation
fix(json-formatter): singularize sibilant and ambiguous -ses plurals in xml and typescript - #467
Merged
Merged
Conversation
…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
requested changes
Nov 4, 2026
anurag629
left a comment
Member
There was a problem hiding this comment.
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,prizesandmazesbecomesiz,prizandmaz, wheredevelopgivessize,prizeandmaze. Only-zzesneeds theesdropped, so I'd keep just that rule.busesbecomesbuse(developgivesbus).- A long
-sesstem still loses too much:responses,courses,releases,licensesanddatabasesgiverespons,cours,releas,licensanddatabas. The stem's ending works better than its length here: dropeswhen the stem ends inss(addresses, classes) or intus,rus,nus,pusorbus(statuses, viruses, bonuses, campuses, buses), and only thesotherwise (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
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what and why
closes #462
fixes incorrect singularization of sibilant plurals and ambiguous
-sesendings in the json formatter.-ches,-shes,-xes,-zes, and doubled-consonant-zzesplurals.-sesendings, includingcases → case,addresses → address, andstatuses → status.categories → category,users → user,boss → bossItem, androot → rootItem.how i tested this
json-utils.test.ts(165/165 tests passed).npm run lint(0 errors).ai assistance
none
type of change
checklist
npm run lint && npm run test && npm run buildpasses locallylib/and have a test inlib/__tests__/page.tsx, client component,opengraph-image.tsx, and the bug report dropdown are all donenotes for reviewers
none