Skip to content

mix format is not idempotent - shorthand collapses require multiple passes #1

@neilberkman

Description

@neilberkman

mix format with canonical_tailwind is not idempotent. A single pass does not produce stable output; running mix format --check-formatted immediately after mix format reports additional changes needed.

Steps to reproduce

  1. Configure canonical_tailwind per the README
  2. Have a file containing e.g. class="h-[48px] w-[48px] flex items-center"
  3. Run mix format
  4. Run mix format --check-formatted

Step 4 fails, reporting the file needs further formatting.

What happens

Pass 1 sorts the classes (reordering h-[48px] and w-[48px] to be adjacent). Pass 2 then sees them adjacent and collapses to the shorthand (size-[48px]). A single pass doesn't do both.

Observed shorthand collapses that only appear on a second pass:

  • h-[48px] w-[48px] -> size-[48px]
  • px-[1.2rem] py-[1.2rem] -> p-[1.2rem]
  • h-[1.8rem] w-[1.8rem] -> size-[1.8rem]

Why this matters

This breaks CI. The standard Phoenix workflow runs mix format --check-formatted in CI to verify formatting. If a single mix format pass doesn't converge, CI will always fail.

Environment

  • canonical_tailwind 0.1.0
  • tailwindcss CLI 4.2.2
  • Elixir 1.19.5 / OTP 28
  • Phoenix LiveView 1.1.27

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamBug in an upstream dependency

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions