Skip to content

[@tailwindcss/upgrade] Don’t migrate inline style properties#19918

Open
dbpolito wants to merge 2 commits intotailwindlabs:mainfrom
dbpolito:fix/ignore-inline-style-candidates
Open

[@tailwindcss/upgrade] Don’t migrate inline style properties#19918
dbpolito wants to merge 2 commits intotailwindlabs:mainfrom
dbpolito:fix/ignore-inline-style-candidates

Conversation

@dbpolito
Copy link
Copy Markdown

@dbpolito dbpolito commented Apr 8, 2026

Prevent the upgrade tool from rewriting CSS properties inside inline style attributes.

This fixes cases like style="flex-grow: 1" being changed to style="grow: 1" and adds regression tests.

dbpolito added 2 commits April 7, 2026 21:47
- treat inline style attributes as unsafe migration contexts
- avoid misclassifying CSS property names like flex-grow and flex-shrink
- add regression coverage for inline style attribute cases
- skip inline style attribute values before candidate parsing
- prevent CSS property names like flex-grow from being treated as utilities
- keep template migration safety checks focused on actual class-like content
@dbpolito dbpolito requested a review from a team as a code owner April 8, 2026 00:59
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9a25c707-ad13-42a1-98fb-0e3b6b3780d3

📥 Commits

Reviewing files that changed from the base of the PR and between aad6017 and 964fc54.

📒 Files selected for processing (2)
  • packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts
  • packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts

Walkthrough

Two files in the Tailwind CSS upgrade codemod package were modified to handle inline style attributes. The test file received two new test cases validating that inline style="flex-grow: 1" and style='flex-shrink: 0' attributes remain unchanged during migration. The source file introduces an INLINE_STYLE_ATTRIBUTE regex pattern and adds a guard condition in the isSafeMigration function to detect when candidates appear within inline style attribute contexts and return false to prevent migration. Additionally, the computation of currentLineBeforeCandidate and currentLineAfterCandidate was relocated earlier in the function execution.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: preventing migration of inline style properties in the upgrade tool.
Description check ✅ Passed The description is directly related to the changeset, explaining what is being fixed and mentioning the regression tests that were added.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant