migrate-variant-order.test.ts — tailwindcss Source File
Architecture documentation for migrate-variant-order.test.ts, a typescript file in the tailwindcss codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5caf09d4_232a_b06e_c5be_c10a64a683f5["migrate-variant-order.test.ts"] 472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"] 5caf09d4_232a_b06e_c5be_c10a64a683f5 --> 472e1b98_afcf_f1f2_ad91_916d742bb731 1490304f_c9fd_75da_db3f_0c12d428c646["migrate-variant-order.ts"] 5caf09d4_232a_b06e_c5be_c10a64a683f5 --> 1490304f_c9fd_75da_db3f_0c12d428c646 d6f03aba_eecb_9486_a7b9_25fc0f87915d["migrateVariantOrder"] 5caf09d4_232a_b06e_c5be_c10a64a683f5 --> d6f03aba_eecb_9486_a7b9_25fc0f87915d 08129f89_e6ef_0092_629d_821c60228c89["node"] 5caf09d4_232a_b06e_c5be_c10a64a683f5 --> 08129f89_e6ef_0092_629d_821c60228c89 8ff4bb92_b963_efb6_cca2_1da4b3ea849b["dedent"] 5caf09d4_232a_b06e_c5be_c10a64a683f5 --> 8ff4bb92_b963_efb6_cca2_1da4b3ea849b f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"] 5caf09d4_232a_b06e_c5be_c10a64a683f5 --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3 style 5caf09d4_232a_b06e_c5be_c10a64a683f5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { __unstable__loadDesignSystem } from '@tailwindcss/node'
import dedent from 'dedent'
import { expect, test, vi } from 'vitest'
import * as versions from '../../utils/version'
import { migrateVariantOrder } from './migrate-variant-order'
vi.spyOn(versions, 'isMajor').mockReturnValue(true)
let css = dedent
test.each([
// Does nothing unless there are at least two variants
['flex', 'flex'],
['hover:flex', 'hover:flex'],
['[color:red]', '[color:red]'],
['[&:focus]:[color:red]', '[&:focus]:[color:red]'],
// Reorders simple variants that include combinators
['*:first:flex', 'first:*:flex'],
// Does not reorder variants without combinators
['data-[invalid]:data-[hover]:flex', 'data-[invalid]:data-[hover]:flex'],
// Does not reorder some known combinations where the order does not matter
['hover:focus:flex', 'hover:focus:flex'],
['focus:hover:flex', 'focus:hover:flex'],
['[&:hover]:[&:focus]:flex', '[&:hover]:[&:focus]:flex'],
['[&:focus]:[&:hover]:flex', '[&:focus]:[&:hover]:flex'],
['data-[a]:data-[b]:flex', 'data-[a]:data-[b]:flex'],
// Handles pseudo-elements that cannot have anything after them
// c.f. https://github.com/tailwindlabs/tailwindcss/pull/13478/files#diff-7779a0eebf6b980dd3abd63b39729b3023cf9a31c91594f5a25ea020b066e1c0
['dark:before:flex', 'dark:before:flex'],
['before:dark:flex', 'dark:before:flex'],
// Puts some pseudo-elements that must appear at the end of the selector at
// the end of the candidate
['dark:*:before:after:flex', 'dark:*:before:after:flex'],
['dark:before:after:*:flex', 'dark:*:before:after:flex'],
// Some pseudo-elements are treated as regular variants
['dark:*:hover:file:focus:underline', 'dark:focus:file:hover:*:underline'],
// Keeps at-rule-variants and the dark variant in the beginning and keeps their
// order
['sm:dark:hover:flex', 'sm:dark:hover:flex'],
['[@media(print)]:group-hover:flex', '[@media(print)]:group-hover:flex'],
['sm:max-xl:data-[a]:data-[b]:dark:hover:flex', 'sm:max-xl:dark:data-[a]:data-[b]:hover:flex'],
[
'sm:data-[root]:*:data-[a]:even:*:data-[b]:even:before:underline',
'sm:even:data-[b]:*:even:data-[a]:*:data-[root]:before:underline',
],
['hover:[@supports(display:grid)]:flex', '[@supports(display:grid)]:hover:flex'],
])('%s => %s', async (candidate, result) => {
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', {
base: __dirname,
})
expect(migrateVariantOrder(designSystem, {}, candidate)).toEqual(result)
})
test('it works with custom variants', async () => {
let designSystem = await __unstable__loadDesignSystem(
css`
@import 'tailwindcss';
@custom-variant atrule {
@media (print) {
@slot;
}
}
@custom-variant combinator {
> * {
@slot;
}
}
@custom-variant pseudo {
&::before {
@slot;
}
}
`,
{
base: __dirname,
},
)
expect(migrateVariantOrder(designSystem, {}, 'combinator:pseudo:atrule:underline')).toEqual(
'atrule:combinator:pseudo:underline',
)
})
Domain
Dependencies
- dedent
- migrate-variant-order.ts
- migrateVariantOrder
- node
- version.ts
- vitest
Source
Frequently Asked Questions
What does migrate-variant-order.test.ts do?
migrate-variant-order.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain.
What does migrate-variant-order.test.ts depend on?
migrate-variant-order.test.ts imports 6 module(s): dedent, migrate-variant-order.ts, migrateVariantOrder, node, version.ts, vitest.
Where is migrate-variant-order.test.ts in the architecture?
migrate-variant-order.test.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate-variant-order.test.ts (domain: CommandLineInterface, 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