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. 2 imports, 3 dependents.

File typescript UpgradeToolkit Codemods 2 imports 3 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  b2513b9e_5a88_8d31_01d5_feda722b6dae["migrate-handle-empty-arbitrary-values.ts"]
  af1a6ece_0432_a556_fd63_8cb4a91f12ad["plugin-api.ts"]
  b2513b9e_5a88_8d31_01d5_feda722b6dae --> af1a6ece_0432_a556_fd63_8cb4a91f12ad
  7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"]
  b2513b9e_5a88_8d31_01d5_feda722b6dae --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a
  832ea6ef_9a32_da8d_2421_b9aa3cf2d588["migrate-handle-empty-arbitrary-values.test.ts"]
  832ea6ef_9a32_da8d_2421_b9aa3cf2d588 --> b2513b9e_5a88_8d31_01d5_feda722b6dae
  ee1d35bf_4335_a131_a900_1f9f4b90a0e1["migrate-modernize-arbitrary-values.test.ts"]
  ee1d35bf_4335_a131_a900_1f9f4b90a0e1 --> b2513b9e_5a88_8d31_01d5_feda722b6dae
  75ba60a9_2614_1c57_ad40_3663d4315f3b["migrate.ts"]
  75ba60a9_2614_1c57_ad40_3663d4315f3b --> b2513b9e_5a88_8d31_01d5_feda722b6dae
  style b2513b9e_5a88_8d31_01d5_feda722b6dae 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 UpgradeToolkit 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 2 module(s): 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: 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