From fd8fd526fc8eb56966b00978576904ab9b86e0fc Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 17 Jun 2025 12:31:37 -0400 Subject: [PATCH 1/2] =?UTF-8?q?Add=20heuristic=20to=20skip=20candidate=20m?= =?UTF-8?q?igrations=20inside=20`emit(=E2=80=A6)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/codemods/template/is-safe-migration.test.ts | 4 ++++ .../src/codemods/template/is-safe-migration.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts index b4c9c01246fc..5ade133e06fc 100644 --- a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts +++ b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts @@ -61,4 +61,8 @@ test('does not replace classes in invalid positions', async () => { // Alpine/Livewire wire:… await shouldNotReplace('', 'blur') + + // Vue 3 events + await shouldNotReplace(`emit('blur', props.modelValue)\n`, 'blur') + await shouldNotReplace(`$emit('blur', props.modelValue)\n`, 'blur') }) diff --git a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts index 27c2e23216ea..7ac24d645fb3 100644 --- a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts +++ b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts @@ -18,6 +18,7 @@ const CONDITIONAL_TEMPLATE_SYNTAX = [ /wire:[^\s]*?$/, ] const NEXT_PLACEHOLDER_PROP = /placeholder=\{?['"]$/ +const VUE_3_EMIT = /\b\$?emit\(['"]$/ export function isSafeMigration( rawCandidate: string, @@ -175,6 +176,11 @@ export function isSafeMigration( return false } + // Heuristic: Disallow replacements inside `emit('…', …)` + if (VUE_3_EMIT.test(currentLineBeforeCandidate)) { + return false + } + return true } From 5142603285e7fd8755839e0e598eb7d17519c234 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 17 Jun 2025 12:32:47 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8106d13895bf..70036c42a1a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +- Add heuristic to skip candidate migrations inside `emit(…)` ([#18330](https://github.com/tailwindlabs/tailwindcss/pull/18330)) ## [4.1.10] - 2025-06-11