-
Notifications
You must be signed in to change notification settings - Fork 28
Rework sorting algorithm to match Prettier Tailwind plugin #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
praveenperera
wants to merge
9
commits into
master
Choose a base branch
from
dev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
63e0423 to
c07901a
Compare
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/)
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Fixes
[&.htmx-request]:h-0now sort correctlyshadow-[0_2px_2px_rgba(0,0,0,0.2)]now sort correctlyTesting
cargo xtask fuzz runBreaking 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.