From 2dcce477062781f2458113f4905b759f5577cbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Chalk?= Date: Wed, 31 Jul 2024 12:25:04 +0200 Subject: [PATCH] refactor(utils): remove unused apostrophize function --- packages/utils/src/index.ts | 1 - packages/utils/src/lib/transform.ts | 9 --------- packages/utils/src/lib/transform.unit.test.ts | 19 ------------------- 3 files changed, 29 deletions(-) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index baacc6714..5c5f8f469 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -86,7 +86,6 @@ export { isSemver, normalizeSemver, sortSemvers } from './lib/semver'; export * from './lib/text-formats'; export { CliArgsObject, - apostrophize, capitalize, countOccurrences, distinct, diff --git a/packages/utils/src/lib/transform.ts b/packages/utils/src/lib/transform.ts index c21eb7088..c3b31583c 100644 --- a/packages/utils/src/lib/transform.ts +++ b/packages/utils/src/lib/transform.ts @@ -139,15 +139,6 @@ export function capitalize(text: T): Capitalize { )}` as Capitalize; } -export function apostrophize(text: string, upperCase?: boolean) { - const lastCharMatch = text.match(/(\w)\W*$/); - const lastChar = lastCharMatch?.[1] ?? ''; - - return `${text}'${ - lastChar.toLocaleLowerCase() === 's' ? '' : upperCase ? 'S' : 's' - }`; -} - export function toNumberPrecision( value: number, decimalPlaces: number, diff --git a/packages/utils/src/lib/transform.unit.test.ts b/packages/utils/src/lib/transform.unit.test.ts index 26c2c9e2b..9a27d94d5 100644 --- a/packages/utils/src/lib/transform.unit.test.ts +++ b/packages/utils/src/lib/transform.unit.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from 'vitest'; import { - apostrophize, capitalize, countOccurrences, deepClone, @@ -262,24 +261,6 @@ describe('capitalize', () => { }); }); -describe('apostrophize', () => { - it("should add apostrophe and 's'", () => { - expect(apostrophize('cli')).toBe("cli's"); - }); - - it("should add apostrophe without 's' for words ending with 's'", () => { - expect(apostrophize('yargs')).toBe("yargs'"); - }); - - it("should add capital 'S' when upper case is defined", () => { - expect(apostrophize('WORLD', true)).toBe("WORLD'S"); - }); - - it('should leave formatting if provided', () => { - expect(apostrophize('`git`')).toBe("`git`'s"); - }); -}); - describe('toNumberPrecision', () => { it.each([ [12.1, 0, 12],