Skip to content

Commit a1ef07e

Browse files
authored
refactor(ensure): replace all lodash string methods with kasi and manual (conventional-changelog#4602)
* refactor(ensure): replace all lodash string methods with kasi and manual * fix: change to kasi
1 parent 2fec7ae commit a1ef07e

File tree

4 files changed

+21
-83
lines changed

4 files changed

+21
-83
lines changed

@commitlint/ensure/package.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,11 @@
3737
"license": "MIT",
3838
"devDependencies": {
3939
"@commitlint/utils": "^20.0.0",
40-
"@types/lodash.camelcase": "^4.3.8",
41-
"@types/lodash.kebabcase": "^4.1.8",
42-
"@types/lodash.snakecase": "^4.1.8",
43-
"@types/lodash.startcase": "^4.4.8",
44-
"@types/lodash.upperfirst": "^4.3.8",
4540
"glob": "^11.0.0"
4641
},
4742
"dependencies": {
4843
"@commitlint/types": "^20.3.1",
49-
"lodash.camelcase": "^4.3.0",
50-
"lodash.kebabcase": "^4.1.1",
51-
"lodash.snakecase": "^4.1.1",
52-
"lodash.startcase": "^4.4.0",
53-
"lodash.upperfirst": "^4.3.1"
44+
"kasi": "^2.0.1"
5445
},
5546
"gitHead": "e82f05a737626bb69979d14564f5ff601997f679"
5647
}

@commitlint/ensure/src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from "node:path";
33
import { fileURLToPath } from "node:url";
44

55
import { globSync } from "glob";
6-
import camelCase from "lodash.camelcase";
6+
import { toCamelCase } from "kasi";
77

88
import * as ensure from "./index.js";
99

@@ -12,7 +12,7 @@ const __dirname = path.resolve(fileURLToPath(import.meta.url), "..");
1212
test("exports all checkers", async () => {
1313
const ignore = ["types"];
1414
const expected = _glob("*.ts")
15-
.map((f) => camelCase(f))
15+
.map((f) => toCamelCase(f))
1616
.sort()
1717
.filter((item) => !ignore.includes(item));
1818
const actual = Object.keys(ensure).sort();

@commitlint/ensure/src/to-case.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
import { TargetCaseType } from "@commitlint/types";
2-
import camelCase from "lodash.camelcase";
3-
import kebabCase from "lodash.kebabcase";
4-
import snakeCase from "lodash.snakecase";
5-
import upperFirst from "lodash.upperfirst";
6-
import startCase from "lodash.startcase";
2+
import {
3+
toCamelCase,
4+
toKebabCase,
5+
toSnakeCase,
6+
toPascalCase,
7+
toTitleCase,
8+
} from "kasi";
79

810
export default function toCase(input: string, target: TargetCaseType): string {
911
switch (target) {
1012
case "camel-case":
11-
return camelCase(input);
13+
return toCamelCase(input);
1214
case "kebab-case":
13-
return kebabCase(input);
15+
return toKebabCase(input);
1416
case "snake-case":
15-
return snakeCase(input);
17+
return toSnakeCase(input);
1618
case "pascal-case":
17-
return upperFirst(camelCase(input));
19+
return toPascalCase(input);
1820
case "start-case":
19-
return startCase(input);
21+
return toTitleCase(input);
2022
case "upper-case":
2123
case "uppercase":
2224
return input.toUpperCase();
2325
case "sentence-case":
2426
case "sentencecase":
25-
return upperFirst(input);
27+
return `${input.charAt(0).toUpperCase()}${input.slice(1)}`;
2628
case "lower-case":
2729
case "lowercase":
2830
case "lowerCase": // Backwards compat config-angular v4

yarn.lock

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,27 +1858,13 @@
18581858
resolved "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76"
18591859
integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==
18601860

1861-
"@types/lodash.camelcase@^4.3.8":
1862-
version "4.3.9"
1863-
resolved "https://registry.npmjs.org/@types/lodash.camelcase/-/lodash.camelcase-4.3.9.tgz#da7b65013d6914fecb8759d5220a6ca9b658ee23"
1864-
integrity sha512-ys9/hGBfsKxzmFI8hckII40V0ASQ83UM2pxfQRghHAwekhH4/jWtjz/3/9YDy7ZpUd/H0k2STSqmPR28dnj7Zg==
1865-
dependencies:
1866-
"@types/lodash" "*"
1867-
18681861
"@types/lodash.isfunction@^3.0.8":
18691862
version "3.0.9"
18701863
resolved "https://registry.npmjs.org/@types/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#527e51ab6638b38c65a03ec218232b1a787cc9bc"
18711864
integrity sha512-BLaDvlY09jnPND1wxlGXPrPl2CN4M7qGRah7Tb/rtB1vnLyZmtcw3FRPSUkDsd5n4e+2E5BBrr0ICfYR+S4hZQ==
18721865
dependencies:
18731866
"@types/lodash" "*"
18741867

1875-
"@types/lodash.kebabcase@^4.1.8":
1876-
version "4.1.9"
1877-
resolved "https://registry.npmjs.org/@types/lodash.kebabcase/-/lodash.kebabcase-4.1.9.tgz#48d3df753b89499e75eba5e017979b560d69df85"
1878-
integrity sha512-kPrrmcVOhSsjAVRovN0lRfrbuidfg0wYsrQa5IYuoQO1fpHHGSme66oyiYA/5eQPVl8Z95OA3HG0+d2SvYC85w==
1879-
dependencies:
1880-
"@types/lodash" "*"
1881-
18821868
"@types/lodash.merge@^4.6.8":
18831869
version "4.6.9"
18841870
resolved "https://registry.npmjs.org/@types/lodash.merge/-/lodash.merge-4.6.9.tgz#93e94796997ed9a3ebe9ccf071ccaec4c6bc8fb8"
@@ -1893,27 +1879,6 @@
18931879
dependencies:
18941880
"@types/lodash" "*"
18951881

1896-
"@types/lodash.snakecase@^4.1.8":
1897-
version "4.1.9"
1898-
resolved "https://registry.npmjs.org/@types/lodash.snakecase/-/lodash.snakecase-4.1.9.tgz#2d2b3313a44500cb6d8a1c598e0353778d4420d2"
1899-
integrity sha512-emBZJUiNlo+QPXr1junMKXwzHJK9zbFvTVdyAoorFcm1YRsbzkZCYPTVMM9AW+dlnA6utG7vpfvOs8alxv/TMw==
1900-
dependencies:
1901-
"@types/lodash" "*"
1902-
1903-
"@types/lodash.startcase@^4.4.8":
1904-
version "4.4.9"
1905-
resolved "https://registry.npmjs.org/@types/lodash.startcase/-/lodash.startcase-4.4.9.tgz#fba0daa4bb5f279e05628c03193ae1d5e32c438d"
1906-
integrity sha512-C0M4DlN1pnn2vEEhLHkTHxiRZ+3GlTegpoAEHHGXnuJkSOXyJMHGiSc+SLRzBlFZWHsBkixe6FqvEAEU04g14g==
1907-
dependencies:
1908-
"@types/lodash" "*"
1909-
1910-
"@types/lodash.upperfirst@^4.3.8":
1911-
version "4.3.9"
1912-
resolved "https://registry.npmjs.org/@types/lodash.upperfirst/-/lodash.upperfirst-4.3.9.tgz#66e150885a67866ed8bc4331c8c305ab682a198c"
1913-
integrity sha512-bYhT1QEsk9/ggrFjK86Pb5bnKJgTBbpVA77Ygbb1aW1oiWJNGRbVjSlQ9We/ihB9vVpX5WqDJvbISXlukGR+dQ==
1914-
dependencies:
1915-
"@types/lodash" "*"
1916-
19171882
"@types/lodash@*":
19181883
version "4.17.16"
19191884
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.16.tgz#94ae78fab4a38d73086e962d0b65c30d816bfb0a"
@@ -5216,6 +5181,11 @@ just-diff@^6.0.0:
52165181
resolved "https://registry.npmjs.org/just-diff/-/just-diff-6.0.2.tgz#03b65908543ac0521caf6d8eb85035f7d27ea285"
52175182
integrity sha512-S59eriX5u3/QhMNq3v/gm8Kd0w8OS6Tz2FS1NG4blv+z0MuQcBRJyFWjdovM0Rad4/P4aUPFtnkNjMjyMlMSYA==
52185183

5184+
kasi@^2.0.1:
5185+
version "2.0.1"
5186+
resolved "https://registry.npmjs.org/kasi/-/kasi-2.0.1.tgz#878e91d06816990bb935fdc8341116a95ef72edd"
5187+
integrity sha512-8qhiHZ1BN26ig1+jQ9fWEk6dj8T1wuxs00QRJfXIANI4scto1EuPUgqj+mxHls52WBfdTNJGQ8yYw9rDpWUcgQ==
5188+
52195189
keyv@^4.5.4:
52205190
version "4.5.4"
52215191
resolved "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93"
@@ -5427,11 +5397,6 @@ locate-path@^7.2.0:
54275397
dependencies:
54285398
p-locate "^6.0.0"
54295399

5430-
lodash.camelcase@^4.3.0:
5431-
version "4.3.0"
5432-
resolved "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
5433-
integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==
5434-
54355400
lodash.clonedeep@^4.5.0:
54365401
version "4.5.0"
54375402
resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
@@ -5447,11 +5412,6 @@ lodash.ismatch@^4.4.0:
54475412
resolved "https://registry.npmjs.org/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"
54485413
integrity sha512-fPMfXjGQEV9Xsq/8MTSgUf255gawYRbjwMyDbcvDhXgV7enSZA0hynz6vMPnpAb5iONEzBHBPsT+0zes5Z301g==
54495414

5450-
lodash.kebabcase@^4.1.1:
5451-
version "4.1.1"
5452-
resolved "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36"
5453-
integrity sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==
5454-
54555415
lodash.map@^4.5.1:
54565416
version "4.6.0"
54575417
resolved "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
@@ -5467,21 +5427,6 @@ lodash.mergewith@^4.6.2:
54675427
resolved "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55"
54685428
integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==
54695429

5470-
lodash.snakecase@^4.1.1:
5471-
version "4.1.1"
5472-
resolved "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d"
5473-
integrity sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==
5474-
5475-
lodash.startcase@^4.4.0:
5476-
version "4.4.0"
5477-
resolved "https://registry.npmjs.org/lodash.startcase/-/lodash.startcase-4.4.0.tgz#9436e34ed26093ed7ffae1936144350915d9add8"
5478-
integrity sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==
5479-
5480-
lodash.upperfirst@^4.3.1:
5481-
version "4.3.1"
5482-
resolved "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce"
5483-
integrity sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==
5484-
54855430
lodash@4.17.21, lodash@^4.17.21:
54865431
version "4.17.21"
54875432
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"

0 commit comments

Comments
 (0)