Skip to content

Commit 0c8eee6

Browse files
committed
ensure blur, rounded and shadow are safe to migrate
1 parent db15235 commit 0c8eee6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Config } from 'tailwindcss'
55
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
66
import { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'
77
import { printCandidate } from '../candidates'
8+
import { isSafeMigration } from '../is-safe-migration'
89

910
const __filename = url.fileURLToPath(import.meta.url)
1011
const __dirname = path.dirname(__filename)
@@ -56,6 +57,11 @@ export async function legacyClasses(
5657
designSystem: DesignSystem,
5758
_userConfig: Config,
5859
rawCandidate: string,
60+
location?: {
61+
contents: string
62+
start: number
63+
end: number
64+
},
5965
): Promise<string> {
6066
// Ensure the "old" classes exist as static utilities to make the migration
6167
// easier because the "root" will point to the full class.
@@ -70,13 +76,14 @@ export async function legacyClasses(
7076

7177
for (let candidate of designSystem.parseCandidate(rawCandidate)) {
7278
if (candidate.kind === 'static' && Object.hasOwn(LEGACY_CLASS_MAP, candidate.root)) {
79+
let newRoot = LEGACY_CLASS_MAP[candidate.root as keyof typeof LEGACY_CLASS_MAP]
80+
81+
if (location && !candidate.root.includes('-') && !isSafeMigration(location)) {
82+
continue
83+
}
84+
7385
let fromThemeKey = THEME_KEYS[candidate.root as keyof typeof THEME_KEYS]
74-
let toThemeKey =
75-
THEME_KEYS[
76-
LEGACY_CLASS_MAP[
77-
candidate.root as keyof typeof LEGACY_CLASS_MAP
78-
] as keyof typeof THEME_KEYS
79-
]
86+
let toThemeKey = THEME_KEYS[newRoot as keyof typeof THEME_KEYS]
8087

8188
if (fromThemeKey && toThemeKey) {
8289
// Migrating something that resolves to a value in the theme.
@@ -104,7 +111,7 @@ export async function legacyClasses(
104111

105112
return printCandidate(designSystem, {
106113
...candidate,
107-
root: LEGACY_CLASS_MAP[candidate.root as keyof typeof LEGACY_CLASS_MAP],
114+
root: newRoot,
108115
})
109116
}
110117
}

0 commit comments

Comments
 (0)