From b189e55b43b8cc0b04631e806a62461b24d6e84d Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 18 Nov 2024 16:16:18 +0100 Subject: [PATCH] do not migrate `group-[]:flex` to `in-[.group]:flex` Because this requires prefixing the `.group` if the prefix is configured. --- .../modernize-arbitrary-values.test.ts | 10 -------- .../codemods/modernize-arbitrary-values.ts | 25 ------------------- 2 files changed, 35 deletions(-) diff --git a/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.test.ts b/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.test.ts index a2e88e326a10..1616067e5423 100644 --- a/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.test.ts +++ b/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.test.ts @@ -19,16 +19,6 @@ test.each([ ['[p_&]:flex', 'in-[p]:flex'], ['[.foo_&]:flex', 'in-[.foo]:flex'], ['[[data-visible]_&]:flex', 'in-data-visible:flex'], - // Some extreme examples of what happens in the wild: - ['group-[]:flex', 'in-[.group]:flex'], - ['group-[]/name:flex', 'in-[.group\\/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'], // nth-child ['[&:nth-child(2)]:flex', 'nth-2:flex'], diff --git a/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.ts b/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.ts index 56b4cd6e3b0e..1773f5119e91 100644 --- a/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.ts +++ b/packages/@tailwindcss-upgrade/src/template/codemods/modernize-arbitrary-values.ts @@ -28,31 +28,6 @@ export function modernizeArbitraryValues( } } - // Promote `group-[]:flex` to `in-[.group]:flex` - // ^^ Yes, this is empty - // Promote `group-[]/name:flex` to `in-[.group\/name]:flex` - if ( - variant.kind === 'compound' && - variant.root === 'group' && - variant.variant.kind === 'arbitrary' && - variant.variant.selector === '&:is()' - ) { - // `group-[]` - if (variant.modifier === null) { - changed = true - Object.assign(variant, designSystem.parseVariant('in-[.group]')) - } - - // `group-[]/name` - else if (variant.modifier.kind === 'named') { - changed = true - Object.assign( - variant, - designSystem.parseVariant(`in-[.group\\/${variant.modifier.value}]`), - ) - } - } - // Expecting an arbitrary variant if (variant.kind !== 'arbitrary') continue