Home / Function/ migrateEmptyArbitraryValues() — tailwindcss Function Reference

migrateEmptyArbitraryValues() — tailwindcss Function Reference

Architecture documentation for the migrateEmptyArbitraryValues() function in migrate-handle-empty-arbitrary-values.ts from the tailwindcss codebase.

Entity Profile

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/codemods/template/migrate-handle-empty-arbitrary-values.ts lines 4–27

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

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free