Skip to content

Add heuristic to skip candidate migrations inside emit(…) #18330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ test('does not replace classes in invalid positions', async () => {

// Alpine/Livewire wire:…
await shouldNotReplace('<x-input.number required="foo" wire:model.blur="coins" />', 'blur')

// Vue 3 events
await shouldNotReplace(`emit('blur', props.modelValue)\n`, 'blur')
await shouldNotReplace(`$emit('blur', props.modelValue)\n`, 'blur')
})
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -175,6 +176,11 @@ export function isSafeMigration(
return false
}

// Heuristic: Disallow replacements inside `emit('…', …)`
if (VUE_3_EMIT.test(currentLineBeforeCandidate)) {
return false
}

return true
}

Expand Down