Skip to content

Commit

Permalink
feat: support snakecase name
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Oct 27, 2022
1 parent 2cf4018 commit 493b585
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@types/js-yaml": "^4.0.5",
"@types/lodash.camelcase": "^4.3.7",
"@types/lodash.kebabcase": "^4.1.7",
"@types/lodash.snakecase": "^4.1.7",
"@types/lodash.uniq": "^4.5.7",
"@types/parse-json": "^4.0.0",
"eslint": "^8.22.0",
Expand All @@ -76,6 +77,7 @@
"js-yaml": "^4.1.0",
"lodash.camelcase": "^4.3.0",
"lodash.kebabcase": "^4.1.1",
"lodash.snakecase": "^4.1.1",
"lodash.uniq": "^4.5.0",
"parse-json": "^6.0.2",
"strip-json-comments": "^5.0.0"
Expand Down
15 changes: 15 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import uniq from 'lodash.uniq'
import camelCase from 'lodash.camelcase'
import kebabCase from 'lodash.kebabcase'
import snakecase from 'lodash.snakecase'

export function getNames(raw: string) {
const candidates: string[] = [
raw,
camelCase(raw),
kebabCase(raw),
snakecase(raw),
]
const names: string[] = uniq(candidates)
return names
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,13 @@
dependencies:
"@types/lodash" "*"

"@types/lodash.snakecase@^4.1.7":
version "4.1.7"
resolved "https://registry.npmmirror.com/@types/lodash.snakecase/-/lodash.snakecase-4.1.7.tgz#2a1ca7cbc08b63e7c3708f6291222e69b0d3216d"
integrity sha512-nv9M+JJokFyfZ9QmaWVXZu2DfT40K0GictZaA8SwXczp3oCzMkjp7PtvUBQyvdoG9SnlCpoRXZDIVwQRzJbd9A==
dependencies:
"@types/lodash" "*"

"@types/lodash.uniq@^4.5.7":
version "4.5.7"
resolved "https://registry.npmmirror.com/@types/lodash.uniq/-/lodash.uniq-4.5.7.tgz#0773960ec0148b29e6a54821a65b878a0ebb5c1a"
Expand Down Expand Up @@ -3195,6 +3202,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.npmmirror.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash.snakecase@^4.1.1:
version "4.1.1"
resolved "https://registry.npmmirror.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d"
integrity sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==

lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.npmmirror.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
Expand Down

0 comments on commit 493b585

Please sign in to comment.