migrate-camelcase-in-named-value.ts — tailwindcss Source File
Architecture documentation for migrate-camelcase-in-named-value.ts, a typescript file in the tailwindcss codebase. 7 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 52b211e0_83d1_a1d7_814c_3d7122a1a27e["migrate-camelcase-in-named-value.ts"] ba6fca27_7720_5839_0f92_bc2abb8db636["candidate.ts"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> ba6fca27_7720_5839_0f92_bc2abb8db636 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310["cloneCandidate"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> 23c6e5a0_eac4_e9dd_7fcf_1e5c71d28310 da5d1116_ab2a_437a_6b13_c1429fd546fa["plugin-api.ts"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> da5d1116_ab2a_437a_6b13_c1429fd546fa 0255ffc0_a3d5_e883_5143_99660766448f["Config"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> 0255ffc0_a3d5_e883_5143_99660766448f bdedd2f6_da4b_69dc_e990_0814b59fbe6e["design-system.ts"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> bdedd2f6_da4b_69dc_e990_0814b59fbe6e 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62["DesignSystem"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62 472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"] 52b211e0_83d1_a1d7_814c_3d7122a1a27e --> 472e1b98_afcf_f1f2_ad91_916d742bb731 eb383a06_7f86_e9c5_3adf_f49fd1939047["migrate-camelcase-in-named-value.test.ts"] eb383a06_7f86_e9c5_3adf_f49fd1939047 --> 52b211e0_83d1_a1d7_814c_3d7122a1a27e e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4["migrate.ts"] e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4 --> 52b211e0_83d1_a1d7_814c_3d7122a1a27e style 52b211e0_83d1_a1d7_814c_3d7122a1a27e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { cloneCandidate } from '../../../../tailwindcss/src/candidate'
import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import * as version from '../../utils/version'
// Converts named values to use kebab-case. This is necessary because the
// upgrade tool also renames the theme values to kebab-case, so `text-superRed`
// will have its theme value renamed to `--color-super-red` and thus the utility
// will be renamed to `text-super-red`.
export function migrateCamelcaseInNamedValue(
designSystem: DesignSystem,
_userConfig: Config | null,
rawCandidate: string,
): string {
if (!version.isMajor(3)) return rawCandidate
for (let candidate of designSystem.parseCandidate(rawCandidate)) {
if (candidate.kind !== 'functional') continue
let clone = cloneCandidate(candidate)
let didChange = false
if (
candidate.value &&
clone.value &&
candidate.value.kind === 'named' &&
clone.value.kind === 'named' &&
candidate.value.value.match(/[A-Z]/)
) {
clone.value.value = camelToKebab(candidate.value.value)
didChange = true
}
if (
candidate.modifier &&
clone.modifier &&
candidate.modifier.kind === 'named' &&
clone.modifier.kind === 'named' &&
candidate.modifier.value.match(/[A-Z]/)
) {
clone.modifier.value = camelToKebab(candidate.modifier.value)
didChange = true
}
if (didChange) {
return designSystem.printCandidate(clone)
}
}
return rawCandidate
}
function camelToKebab(str: string): string {
return str.replace(/([A-Z])/g, '-$1').toLowerCase()
}
Domain
Subdomains
Imported By
Source
Frequently Asked Questions
What does migrate-camelcase-in-named-value.ts do?
migrate-camelcase-in-named-value.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Codemods subdomain.
What functions are defined in migrate-camelcase-in-named-value.ts?
migrate-camelcase-in-named-value.ts defines 2 function(s): camelToKebab, migrateCamelcaseInNamedValue.
What does migrate-camelcase-in-named-value.ts depend on?
migrate-camelcase-in-named-value.ts imports 7 module(s): Config, DesignSystem, candidate.ts, cloneCandidate, design-system.ts, plugin-api.ts, version.ts.
What files import migrate-camelcase-in-named-value.ts?
migrate-camelcase-in-named-value.ts is imported by 2 file(s): migrate-camelcase-in-named-value.test.ts, migrate.ts.
Where is migrate-camelcase-in-named-value.ts in the architecture?
migrate-camelcase-in-named-value.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate-camelcase-in-named-value.ts (domain: CommandLineInterface, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/template).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free