Skip to content

Commit 4e00747

Browse files
authored
[DevTools] Don't pluralize if already plural (#34870)
In a demo today, `cookies()` showed up as `cookieses`. While adorable, is wrong.
1 parent 7bd8716 commit 4e00747

File tree

1 file changed

+21
-0
lines changed
  • packages/react-devtools-shared/src/devtools/views

1 file changed

+21
-0
lines changed

packages/react-devtools-shared/src/devtools/views/utils.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@ export function pluralize(word: string): string {
205205
return word;
206206
}
207207

208+
// Bail out if it's already plural.
209+
switch (word) {
210+
case 'men':
211+
case 'women':
212+
case 'children':
213+
case 'feet':
214+
case 'teeth':
215+
case 'mice':
216+
case 'people':
217+
return word;
218+
}
219+
220+
if (
221+
/(ches|shes|ses|xes|zes)$/i.test(word) ||
222+
/[^s]ies$/i.test(word) ||
223+
/ves$/i.test(word) ||
224+
/[^s]s$/i.test(word)
225+
) {
226+
return word;
227+
}
228+
208229
switch (word) {
209230
case 'man':
210231
return 'men';

0 commit comments

Comments
 (0)