Home / File/ migrate-handle-empty-arbitrary-values.ts — tailwindcss Source File

migrate-handle-empty-arbitrary-values.ts — tailwindcss Source File

Architecture documentation for migrate-handle-empty-arbitrary-values.ts, a typescript file in the tailwindcss codebase. 4 imports, 3 dependents.

File typescript CommandLineInterface Codemods 4 imports 3 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  ca0b656a_eb12_8775_7c9e_8ec36fc0519a["migrate-handle-empty-arbitrary-values.ts"]
  da5d1116_ab2a_437a_6b13_c1429fd546fa["plugin-api.ts"]
  ca0b656a_eb12_8775_7c9e_8ec36fc0519a --> da5d1116_ab2a_437a_6b13_c1429fd546fa
  0255ffc0_a3d5_e883_5143_99660766448f["Config"]
  ca0b656a_eb12_8775_7c9e_8ec36fc0519a --> 0255ffc0_a3d5_e883_5143_99660766448f
  bdedd2f6_da4b_69dc_e990_0814b59fbe6e["design-system.ts"]
  ca0b656a_eb12_8775_7c9e_8ec36fc0519a --> bdedd2f6_da4b_69dc_e990_0814b59fbe6e
  665aa4ed_d86e_30e5_80d5_cd56b8ca8b62["DesignSystem"]
  ca0b656a_eb12_8775_7c9e_8ec36fc0519a --> 665aa4ed_d86e_30e5_80d5_cd56b8ca8b62
  d51977aa_e57d_6179_0d9a_3c91e11a2a64["migrate-handle-empty-arbitrary-values.test.ts"]
  d51977aa_e57d_6179_0d9a_3c91e11a2a64 --> ca0b656a_eb12_8775_7c9e_8ec36fc0519a
  80bb9840_1d91_d6ca_549c_09209ffc25a6["migrate-modernize-arbitrary-values.test.ts"]
  80bb9840_1d91_d6ca_549c_09209ffc25a6 --> ca0b656a_eb12_8775_7c9e_8ec36fc0519a
  e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4["migrate.ts"]
  e39bed3f_bfbf_a8c6_90a0_aa2ce3be1ef4 --> ca0b656a_eb12_8775_7c9e_8ec36fc0519a
  style ca0b656a_eb12_8775_7c9e_8ec36fc0519a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'

export function migrateEmptyArbitraryValues(
  designSystem: DesignSystem,
  _userConfig: Config | null,
  rawCandidate: string,
): string {
  // We can parse the candidate, nothing to do
  if (designSystem.parseCandidate(rawCandidate).length > 0) {
    return rawCandidate
  }

  // No need to handle empty arbitrary values
  if (!rawCandidate.includes('[]')) {
    return rawCandidate
  }

  // Add the `&` placeholder to the empty arbitrary values. Other codemods might
  // migrate these away, but if not, then it's at least valid to parse.
  //
  // E.g.: `group-[]:flex` => `group-[&]:flex`
  // E.g.: `group-[]/name:flex` => `group-[&]/name:flex`
  return rawCandidate
    .replaceAll('-[]:', '-[&]:') // End of variant
    .replaceAll('-[]/', '-[&]/') // With modifier
}

Subdomains

Frequently Asked Questions

What does migrate-handle-empty-arbitrary-values.ts do?
migrate-handle-empty-arbitrary-values.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 migrate-handle-empty-arbitrary-values.ts?
migrate-handle-empty-arbitrary-values.ts defines 1 function(s): migrateEmptyArbitraryValues.
What does migrate-handle-empty-arbitrary-values.ts depend on?
migrate-handle-empty-arbitrary-values.ts imports 4 module(s): Config, DesignSystem, design-system.ts, plugin-api.ts.
What files import migrate-handle-empty-arbitrary-values.ts?
migrate-handle-empty-arbitrary-values.ts is imported by 3 file(s): migrate-handle-empty-arbitrary-values.test.ts, migrate-modernize-arbitrary-values.test.ts, migrate.ts.
Where is migrate-handle-empty-arbitrary-values.ts in the architecture?
migrate-handle-empty-arbitrary-values.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/migrate-handle-empty-arbitrary-values.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