From 4ee3d73413547c095fbbca9e77051bec6b41d7b2 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Mon, 21 Oct 2024 17:31:02 +0200 Subject: [PATCH] Replace lodash imports --- src/configs/getAndroidConfig.ts | 4 ++-- src/configs/getWebConfig.ts | 8 +++----- src/transforms/kotlin/svgToDrawable.ts | 4 ++-- src/transforms/swift/tokenTICamel.ts | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/configs/getAndroidConfig.ts b/src/configs/getAndroidConfig.ts index bfd1db7..afc7846 100644 --- a/src/configs/getAndroidConfig.ts +++ b/src/configs/getAndroidConfig.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import _ from "lodash-es"; +import { camelCase, upperFirst } from "lodash-es"; import StyleDictionary from "style-dictionary"; import type { FormatFnArguments, @@ -123,7 +123,7 @@ export function getAndroidConfig(theme: Theme): PlatformConfig { name: "compose/icons", format: composeIcons, }); - const className = _.upperFirst(_.camelCase(theme)); + const className = upperFirst(camelCase(theme)); let valName = ""; let themeName = ""; let tokenClassName = ""; diff --git a/src/configs/getWebConfig.ts b/src/configs/getWebConfig.ts index 43964c6..245c025 100644 --- a/src/configs/getWebConfig.ts +++ b/src/configs/getWebConfig.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import _ from "lodash-es"; +import { camelCase } from "lodash-es"; import type { File, PlatformConfig } from "style-dictionary/types"; import type { Theme } from "../@types"; import { isCoreColor } from "../filters/isCoreColor"; @@ -63,7 +63,7 @@ function getFilesFormat(theme: Theme, target: "css" | "js" | "ts"): File[] { if (target === "ts") { return [ { - destination: `${_.camelCase( + destination: `${camelCase( `${COMPOUND_TOKENS_NAMESPACE}.${theme}`, )}.d.ts`, format: "typescript/es6-declarations", @@ -74,9 +74,7 @@ function getFilesFormat(theme: Theme, target: "css" | "js" | "ts"): File[] { if (target === "js") { return [ { - destination: `${_.camelCase( - `${COMPOUND_TOKENS_NAMESPACE}.${theme}`, - )}.js`, + destination: `${camelCase(`${COMPOUND_TOKENS_NAMESPACE}.${theme}`)}.js`, format: "javascript/es6", options, }, diff --git a/src/transforms/kotlin/svgToDrawable.ts b/src/transforms/kotlin/svgToDrawable.ts index 29dc8a1..102df25 100644 --- a/src/transforms/kotlin/svgToDrawable.ts +++ b/src/transforms/kotlin/svgToDrawable.ts @@ -17,7 +17,7 @@ limitations under the License. import path from "node:path"; import { fileURLToPath } from "node:url"; import fs from "fs-extra"; -import _ from "lodash-es"; +import { snakeCase } from "lodash-es"; import type { Transform } from "style-dictionary/types"; import svg2vectordrawable from "svg2vectordrawable"; @@ -38,7 +38,7 @@ export default { // Snake case and replace `icon` with `ic` as this is the convention on Android // and on Material - const imageId = _.snakeCase(token.name.replace("icon", "ic_compound_")); + const imageId = snakeCase(token.name.replace("icon", "ic_compound_")); const options = { fillBlack: true, // Add black color to path element, defaults to false diff --git a/src/transforms/swift/tokenTICamel.ts b/src/transforms/swift/tokenTICamel.ts index 73e8b30..02a1c40 100644 --- a/src/transforms/swift/tokenTICamel.ts +++ b/src/transforms/swift/tokenTICamel.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import _ from "lodash-es"; +import { camelCase } from "lodash-es"; import type { Transform } from "style-dictionary/types"; /** @@ -30,7 +30,7 @@ export default { if (options?.prefix) { prefix = options.prefix; } - const name = _.camelCase( + const name = camelCase( [prefix].concat(token.path.slice(1, token.path.length)).join(" "), ); return escapeName(name);