Skip to content

Commit 5fc6698

Browse files
Add heuristic to skip candidate migrations inside emit(…) (#18330)
Fixes #18318
1 parent 4453496 commit 5fc6698

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
- Add heuristic to skip candidate migrations inside `emit(…)` ([#18330](https://github.com/tailwindlabs/tailwindcss/pull/18330))
1111

1212
## [4.1.10] - 2025-06-11
1313

packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,8 @@ test('does not replace classes in invalid positions', async () => {
6161

6262
// Alpine/Livewire wire:…
6363
await shouldNotReplace('<x-input.number required="foo" wire:model.blur="coins" />', 'blur')
64+
65+
// Vue 3 events
66+
await shouldNotReplace(`emit('blur', props.modelValue)\n`, 'blur')
67+
await shouldNotReplace(`$emit('blur', props.modelValue)\n`, 'blur')
6468
})

packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const CONDITIONAL_TEMPLATE_SYNTAX = [
1818
/wire:[^\s]*?$/,
1919
]
2020
const NEXT_PLACEHOLDER_PROP = /placeholder=\{?['"]$/
21+
const VUE_3_EMIT = /\b\$?emit\(['"]$/
2122

2223
export function isSafeMigration(
2324
rawCandidate: string,
@@ -175,6 +176,11 @@ export function isSafeMigration(
175176
return false
176177
}
177178

179+
// Heuristic: Disallow replacements inside `emit('…', …)`
180+
if (VUE_3_EMIT.test(currentLineBeforeCandidate)) {
181+
return false
182+
}
183+
178184
return true
179185
}
180186

0 commit comments

Comments
 (0)