migrate-modernize-arbitrary-values.test.ts — tailwindcss Source File
Architecture documentation for migrate-modernize-arbitrary-values.test.ts, a typescript file in the tailwindcss codebase. 15 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 80bb9840_1d91_d6ca_549c_09209ffc25a6["migrate-modernize-arbitrary-values.test.ts"] 479eaf18_f640_94ff_bd07_456688f9ac14["types.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 479eaf18_f640_94ff_bd07_456688f9ac14 f049ff67_bd94_009a_5905_62bd3c9f309b["UserConfig"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> f049ff67_bd94_009a_5905_62bd3c9f309b bdedd2f6_da4b_69dc_e990_0814b59fbe6e["design-system.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> bdedd2f6_da4b_69dc_e990_0814b59fbe6e 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62["DesignSystem"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62 472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 472e1b98_afcf_f1f2_ad91_916d742bb731 fd9821c7_1a1a_545c_2d82_048fc3c3d870["migrate-arbitrary-variants.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> fd9821c7_1a1a_545c_2d82_048fc3c3d870 7a380dd4_2f8e_5aa7_b4ee_bf219cb7807f["migrateArbitraryVariants"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 7a380dd4_2f8e_5aa7_b4ee_bf219cb7807f ca0b656a_eb12_8775_7c9e_8ec36fc0519a["migrate-handle-empty-arbitrary-values.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> ca0b656a_eb12_8775_7c9e_8ec36fc0519a c21053c4_bf58_de9a_aac7_84c86dc78bd3["migrateEmptyArbitraryValues"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> c21053c4_bf58_de9a_aac7_84c86dc78bd3 5d3b10aa_da00_02c8_3f52_47b3ae3aa06e["migrate-modernize-arbitrary-values.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 5d3b10aa_da00_02c8_3f52_47b3ae3aa06e 95e8edc9_45de_ca00_e4d2_601d3ae22f9f["migrateModernizeArbitraryValues"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 95e8edc9_45de_ca00_e4d2_601d3ae22f9f e4e5ac2c_0d58_689d_0ad6_7086823787f1["migrate-prefix.ts"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> e4e5ac2c_0d58_689d_0ad6_7086823787f1 7a457be5_eaef_02ce_7bc4_4e0317ecd8ce["migratePrefix"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 7a457be5_eaef_02ce_7bc4_4e0317ecd8ce 08129f89_e6ef_0092_629d_821c60228c89["node"] 80bb9840_1d91_d6ca_549c_09209ffc25a6 --> 08129f89_e6ef_0092_629d_821c60228c89 style 80bb9840_1d91_d6ca_549c_09209ffc25a6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { __unstable__loadDesignSystem } from '@tailwindcss/node'
import { expect, test, vi } from 'vitest'
import type { UserConfig } from '../../../../tailwindcss/src/compat/config/types'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import * as versions from '../../utils/version'
import { migrateArbitraryVariants } from './migrate-arbitrary-variants'
import { migrateEmptyArbitraryValues } from './migrate-handle-empty-arbitrary-values'
import { migrateModernizeArbitraryValues } from './migrate-modernize-arbitrary-values'
import { migratePrefix } from './migrate-prefix'
vi.spyOn(versions, 'isMajor').mockReturnValue(true)
const css = String.raw
function migrate(designSystem: DesignSystem, userConfig: UserConfig | null, rawCandidate: string) {
for (let migration of [
migrateEmptyArbitraryValues,
migratePrefix,
migrateModernizeArbitraryValues,
migrateArbitraryVariants,
(designSystem: DesignSystem, _: UserConfig | null, rawCandidate: string) => {
return designSystem.canonicalizeCandidates([rawCandidate]).pop() ?? rawCandidate
},
]) {
rawCandidate = migration(designSystem, userConfig, rawCandidate)
}
return rawCandidate
}
test.each([
// Some extreme examples of what happens in the wild:
['group-[]:flex', 'in-[.group]:flex'],
['group-[]/name:flex', 'in-[.group\\/name]:flex'],
// Migrate `peer-[]` to a parsable `peer-[&]` instead:
['peer-[]:flex', 'peer-[&]:flex'],
['peer-[]/name:flex', 'peer-[&]/name:flex'],
// These shouldn't happen in the real world (because compound variants are
// new). But this could happen once we allow codemods to run in v4+ projects.
['has-group-[]:flex', 'has-in-[.group]:flex'],
['has-group-[]/name:flex', 'has-in-[.group\\/name]:flex'],
['not-group-[]:flex', 'not-in-[.group]:flex'],
['not-group-[]/name:flex', 'not-in-[.group\\/name]:flex'],
])('%s => %s (%#)', async (candidate, result) => {
let designSystem = await __unstable__loadDesignSystem(
css`
@import 'tailwindcss';
@theme {
--*: initial;
}
`,
{ base: __dirname },
)
expect(migrate(designSystem, {}, candidate)).toEqual(result)
})
test.each([
// Should not prefix classes in arbitrary values
['[.foo_&]:tw-flex', 'tw:in-[.foo]:flex'],
// Should migrate `.group` classes
['group-[]:tw-flex', 'tw:in-[.tw\\:group]:flex'],
['group-[]/name:tw-flex', 'tw:in-[.tw\\:group\\/name]:flex'],
// Migrate `peer-[]` to a parsable `peer-[&]` instead:
['peer-[]:tw-flex', 'tw:peer-[&]:flex'],
['peer-[]/name:tw-flex', 'tw:peer-[&]/name:flex'],
// However, `.group` inside of an arbitrary variant should not be prefixed:
['[.group_&]:tw-flex', 'tw:in-[.group]:flex'],
// These shouldn't happen in the real world (because compound variants are
// new). But this could happen once we allow codemods to run in v4+ projects.
['has-group-[]:tw-flex', 'tw:has-in-[.tw\\:group]:flex'],
['has-group-[]/name:tw-flex', 'tw:has-in-[.tw\\:group\\/name]:flex'],
['not-group-[]:tw-flex', 'tw:not-in-[.tw\\:group]:flex'],
['not-group-[]/name:tw-flex', 'tw:not-in-[.tw\\:group\\/name]:flex'],
])('%s => %s (%#)', async (candidate, result) => {
let designSystem = await __unstable__loadDesignSystem(
css`
@import 'tailwindcss' prefix(tw);
@theme {
--*: initial;
}
`,
{ base: __dirname },
)
expect(migrate(designSystem, { prefix: 'tw-' }, candidate)).toEqual(result)
})
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does migrate-modernize-arbitrary-values.test.ts do?
migrate-modernize-arbitrary-values.test.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-modernize-arbitrary-values.test.ts?
migrate-modernize-arbitrary-values.test.ts defines 1 function(s): migrate.
What does migrate-modernize-arbitrary-values.test.ts depend on?
migrate-modernize-arbitrary-values.test.ts imports 15 module(s): DesignSystem, UserConfig, design-system.ts, migrate-arbitrary-variants.ts, migrate-handle-empty-arbitrary-values.ts, migrate-modernize-arbitrary-values.ts, migrate-prefix.ts, migrateArbitraryVariants, and 7 more.
Where is migrate-modernize-arbitrary-values.test.ts in the architecture?
migrate-modernize-arbitrary-values.test.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate-modernize-arbitrary-values.test.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