Skip to content

fix(config): pluralize names ending in consonant+y as 'ies'#81

Merged
Emyrk merged 3 commits into
mainfrom
fix/pluralize-y-suffix
May 11, 2026
Merged

fix(config): pluralize names ending in consonant+y as 'ies'#81
Emyrk merged 3 commits into
mainfrom
fix/pluralize-y-suffix

Conversation

@evgeniy-scherbina
Copy link
Copy Markdown
Contributor

@evgeniy-scherbina evgeniy-scherbina commented May 11, 2026

EnumLists derives a list constant name from each enum type's name using a small suffix heuristic, but it only handled x / s / z and ch / sh. Type names ending in y were left to the default rule of "just append s", so Policy became Policys, Story became Storys, and so on.

The standard English rule for consonant + y is to drop the y and append ies; vowel + y just appends s. Apply that rule, move the heuristic into a pluralize helper, and cover the cases with a unit test.

This already affects coder/coder, where HealthSeverity currently generates HealthSeveritys in typesGenerated.ts.

The helper remains best-effort and does not try to recognize already-plural inputs (AutomaticUpdates -> AutomaticUpdateses) or irregular plurals (Person -> Persons). Those are out of scope for this fix.

Triggered by coder/coder#25122


This PR was opened by a Coder agent on behalf of @evgeniy-scherbina.

EnumLists used a simple suffix rule that handled x/s/z and ch/sh
but ignored the y -> ies rule. Type names like Policy or
HealthSeverity produced Policys and HealthSeveritys.

Apply the standard English rule: consonant + y drops the y and
appends ies, vowel + y just appends s. Move the heuristic into a
pluralize helper and cover the cases with a unit test.
- Drop redundant c := c loop-variable rebind (Go 1.22+ scoping).
- Use testify/require.Equal in the table test.
- Generalize pluralize godoc to not tie it to EnumLists.
- Trim two redundant test cases.
@evgeniy-scherbina evgeniy-scherbina marked this pull request as ready for review May 11, 2026 19:39
@evgeniy-scherbina evgeniy-scherbina requested a review from Emyrk May 11, 2026 19:39
@Emyrk Emyrk merged commit c0d0751 into main May 11, 2026
1 check passed
evgeniy-scherbina added a commit to coder/coder that referenced this pull request May 11, 2026
Bump coder/guts to v1.7.0.
Related PR: coder/guts#81
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.

2 participants