Skip to content

Conversation

@praveenperera
Copy link
Member

@praveenperera praveenperera commented Dec 8, 2025

Summary

This PR completely reworks the Tailwind class sorting algorithm to match the behavior of the official prettier-plugin-tailwindcss. The new implementation uses pattern-based utility matching with property ordering derived from Tailwind's CSS output.

Key changes:

  • Pattern-based sorting - Utilities are matched against patterns and sorted by CSS property order
  • Proper variant ordering - Variants (hover, focus, sm, md, etc.) now sort exactly like Prettier
  • Improved class parsing - Better handling of complex class names with variants and modifiers
  • Hybrid fallback - Unrecognized classes fall back gracefully while maintaining sort stability

Fixes

Testing

  • Added comprehensive integration tests covering all utility categories
  • Added fuzz testing suite that validates against prettier-plugin-tailwindcss
  • Current fuzz test pass rate: 99% compatibility with Prettier
  • Run fuzz tests with: cargo xtask fuzz run

Breaking Changes

The sort order will change for most class strings to match Prettier's behavior. This is intentional - the goal is 1:1 compatibility with the official Tailwind tooling.

This reworks the sorting algorithm to match the official Prettier
Tailwind CSS plugin. The new implementation uses:

- Pattern-based utility matching with property order from Tailwind's CSS
- Variant ordering that matches Prettier's sort behavior
- Hybrid sorting that combines pattern matching with legacy fallbacks
- Improved class parsing for complex class names with variants
Includes tests for:
- Utility category ordering (spacing, colors, typography, etc.)
- Variant stacking and ordering
- Opacity modifiers and slash syntax
- Ring/shadow color ordering
- Transform and rotation utilities
- Break, snap, and touch utilities
- Background color and divide ordering
@praveenperera praveenperera marked this pull request as draft December 8, 2025 15:44
@praveenperera praveenperera force-pushed the dev branch 3 times, most recently from 63e0423 to c07901a Compare December 8, 2025 16:57
@praveenperera praveenperera marked this pull request as ready for review December 8, 2025 16:58
Generates random Tailwind class combinations and compares RustyWind's
output against the official prettier-plugin-tailwindcss. Includes:

- Random class combination generator with variants
- Comparison scripts for validating sorting behavior
- Regression tests capturing discovered edge cases
- Documentation on Tailwind's sorting algorithm
- Add xtask to workspace members
- Update dependencies for pattern sorter
- Add sorting benchmarks for performance testing
- Update gitignore for Claude Code settings
Introduces a new npm distribution system using optionalDependencies
to install platform-specific binaries. This replaces the old approach
of downloading binaries at postinstall time.

New packages:
- rustywind (main package with JS wrapper fallback)
- rustywind-darwin-arm64
- rustywind-darwin-x64
- rustywind-linux-arm64-gnu
- rustywind-linux-arm64-musl
- rustywind-linux-x64-musl
- rustywind-linux-arm-gnueabihf
- rustywind-win32-x64-msvc
- rustywind-win32-ia32-msvc
New xtask commands for managing npm package releases:
- `cargo xtask npm update-version <version>` - Update all package.json versions
- `cargo xtask npm prepare-binaries <version>` - Download binaries from GitHub releases
- `cargo xtask npm publish` - Publish all packages to npm
- `cargo xtask npm bump <major|minor|patch|version>` - Full release workflow

Also adds the publish-npm job to the GitHub Actions workflow to
automatically publish npm packages when a new release is tagged.
The old npm packaging system downloaded binaries at postinstall time.
This has been replaced by platform-specific optional dependencies
which provide a better installation experience.

Removed:
- npm/lib/ - old download and wrapper scripts
- npm/package.json - old root package (replaced by npm/packages/rustywind/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fails to sort with arbitrary variant classes Fails to sort for arbitrary-value class Confusing order with screens and states

2 participants