Home / File/ is-safe-migration.ts — tailwindcss Source File

is-safe-migration.ts — tailwindcss Source File

Architecture documentation for is-safe-migration.ts, a typescript file in the tailwindcss codebase. 7 imports, 1 dependents.

File typescript CommandLineInterface Codemods 7 imports 1 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  d5e14c3d_f7c4_162e_96e8_83915119d547["is-safe-migration.ts"]
  ba6fca27_7720_5839_0f92_bc2abb8db636["candidate.ts"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> ba6fca27_7720_5839_0f92_bc2abb8db636
  7d328a86_10c6_b5c1_6390_36f4fffe9c14["parseCandidate"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> 7d328a86_10c6_b5c1_6390_36f4fffe9c14
  bdedd2f6_da4b_69dc_e990_0814b59fbe6e["design-system.ts"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> bdedd2f6_da4b_69dc_e990_0814b59fbe6e
  665aa4ed_d86e_30e5_80d5_cd56b8ca8b62["DesignSystem"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62
  28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> 28a2f72d_350c_6647_bf9d_77c69e637045
  cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> cfb4af0e_7b2d_34a1_693a_90088443cfec
  472e1b98_afcf_f1f2_ad91_916d742bb731["version.ts"]
  d5e14c3d_f7c4_162e_96e8_83915119d547 --> 472e1b98_afcf_f1f2_ad91_916d742bb731
  e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4["migrate.ts"]
  e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4 --> d5e14c3d_f7c4_162e_96e8_83915119d547
  style d5e14c3d_f7c4_162e_96e8_83915119d547 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)

Subdomains

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 CommandLineInterface 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 7 module(s): DefaultMap, DesignSystem, 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: CommandLineInterface, 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