From f83041852dc504febcad15ba53d5f1a6c93ccd64 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Thu, 24 Oct 2024 22:11:59 +0200 Subject: [PATCH] Handle feedback from #14783 (#14788) This PR is a continuation of #14783 to handle the feedback on that PR. 1. Update the test to be more realistic 2. Updated the comment --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com> --- integrations/upgrade/index.test.ts | 10 +++++----- packages/@tailwindcss-upgrade/src/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integrations/upgrade/index.test.ts b/integrations/upgrade/index.test.ts index 3680e8ae3..cd89f6d38 100644 --- a/integrations/upgrade/index.test.ts +++ b/integrations/upgrade/index.test.ts @@ -1560,7 +1560,7 @@ test( `, 'tailwind.config.js': js`module.exports = {}`, 'src/index.css': css` - @import 'tailwindcss/utilities'; + @import 'tailwindcss/components'; /* No layer expected */ @import './my-components.css'; @@ -1571,7 +1571,7 @@ test( /* Expecting a layer */ @import './my-other.css'; - @import 'tailwindcss/components'; + @import 'tailwindcss/utilities'; `, 'src/my-components.css': css` @layer components { @@ -1600,8 +1600,6 @@ test( expect(await fs.dumpFiles('./src/**/*.css')).toMatchInlineSnapshot(` " --- ./src/index.css --- - @import 'tailwindcss/utilities' layer(utilities); - /* No layer expected */ @import './my-components.css'; @@ -1609,7 +1607,9 @@ test( @import './my-utilities.css'; /* Expecting a layer */ - @import './my-other.css' layer(utilities); + @import './my-other.css' layer(components); + + @import 'tailwindcss/utilities' layer(utilities); --- ./src/my-components.css --- @utility foo { diff --git a/packages/@tailwindcss-upgrade/src/index.ts b/packages/@tailwindcss-upgrade/src/index.ts index b2f211b45..46b1fd672 100644 --- a/packages/@tailwindcss-upgrade/src/index.ts +++ b/packages/@tailwindcss-upgrade/src/index.ts @@ -158,8 +158,8 @@ async function run() { ) if (!importedSheet) continue - // Only remove the `layer(…)` next to the import, if any of the children - // contains an `@utility`. Otherwise the `@utility` will not be top-level. + // Only remove the `layer(…)` next to the import if any of the children + // contain `@utility`. Otherwise `@utility` will not be top-level. if ( !importedSheet.containsRule((node) => node.type === 'atrule' && node.name === 'utility') ) {