is-safe-migration.ts — tailwindcss Source File
Architecture documentation for is-safe-migration.ts, a typescript file in the tailwindcss codebase. 6 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79["is-safe-migration.ts"] 669e6a28_c71f_3c5e_9c53_915cede7da78["candidate.ts"] 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 --> 669e6a28_c71f_3c5e_9c53_915cede7da78 d4b90da0_01b5_b21d_ff05_b37798744576["parseCandidate"] 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 --> d4b90da0_01b5_b21d_ff05_b37798744576 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"] 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a c056448b_f7a2_9149_54e8_f0f8470fe3aa["default-map.ts"] 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 --> c056448b_f7a2_9149_54e8_f0f8470fe3aa bf2992f6_4a37_8536_70f8_94b13631027d["DefaultMap"] 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 --> bf2992f6_4a37_8536_70f8_94b13631027d fff09679_e13c_392d_23bb_cebc04ddb008["version.ts"] 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 --> fff09679_e13c_392d_23bb_cebc04ddb008 75ba60a9_2614_1c57_ad40_3663d4315f3b["migrate.ts"] 75ba60a9_2614_1c57_ad40_3663d4315f3b --> 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 style 0e3e8c5a_e3ef_6c0d_8a31_e358e2206f79 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { parseCandidate } from '../../../../tailwindcss/src/candidate'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'
import * as version from '../../utils/version'
const LOGICAL_OPERATORS = ['&&', '||', '?', '===', '==', '!=', '!==', '>', '>=', '<', '<=']
const CONDITIONAL_TEMPLATE_SYNTAX = [
// Skip any generic attributes like `xxx="shadow"`,
// including Vue conditions like `v-if="something && shadow"`
// and Alpine conditions like `x-if="shadow"`,
// but allow Vue and React classes
/(?<!:?class|className)=['"]$/i,
// JavaScript / TypeScript
/addEventListener\(['"`]$/,
// Alpine
/wire:[^\s]*?$/,
// shadcn/ui variants
/variant\s*[:=]\s*\{?['"`]$/,
]
const NEXT_PLACEHOLDER_PROP = /placeholder=\{?['"`]$/
const VUE_3_EMIT = /\b\$?emit\(['"`]$/
export function isSafeMigration(
rawCandidate: string,
location: { contents: string; start: number; end: number },
designSystem: DesignSystem,
): boolean {
// Ensure we are not migrating a candidate in a `<style>` block. The heuristic
// would be if the candidate is preceded by a whitespace and followed by a
// colon and whitespace.
//
// E.g.:
// ```vue
// <template>
// <div class="foo"></div>
// </template>
//
//
// <style>
// .foo {
// flex-shrink: 0;
// ^ ^^
// }
// </style>
// ```
if (
// Whitespace before the candidate
location.contents[location.start - 1]?.match(/\s/) &&
// A colon followed by whitespace after the candidate
location.contents.slice(location.end, location.end + 2)?.match(/^:\s/)
) {
// Compute all `<style>` ranges once and cache it for the current files
let ranges = styleBlockRanges.get(location.contents)
for (let i = 0; i < ranges.length; i += 2) {
let start = ranges[i]
let end = ranges[i + 1]
// ... (191 more lines)
Domain
Subdomains
Source
Frequently Asked Questions
What does is-safe-migration.ts do?
is-safe-migration.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain, Codemods subdomain.
What functions are defined in is-safe-migration.ts?
is-safe-migration.ts defines 3 function(s): isMiddleOfString, isSafeMigration, styleBlockRanges.
What does is-safe-migration.ts depend on?
is-safe-migration.ts imports 6 module(s): DefaultMap, candidate.ts, default-map.ts, design-system.ts, parseCandidate, version.ts.
What files import is-safe-migration.ts?
is-safe-migration.ts is imported by 1 file(s): migrate.ts.
Where is is-safe-migration.ts in the architecture?
is-safe-migration.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts (domain: UpgradeToolkit, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/template).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free