Sort named design-system colors as known - #150
Conversation
Classify arbitrary named design-system values such as bg-muted, text-foreground, and bg-card/90 as color utilities so they sort like Prettier. Side border names map to border color rather than width; shadow-family names stay unclassified because they are ambiguous with custom sizes. The parity harness now includes a shadcn-style semantic palette for grading these tokens.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughNamed design-system theme values are recognized as color utilities across Tailwind utility families. Sorting, opacity, ring, CLI, parity-harness, CI, and documentation updates reflect configurable named-color inference. ChangesNamed color inference
Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge duplicate color-like and named-color arms into single guards, simplify is_named_color_value, expand side-border and keyword coverage, and clarify the changelog note about shadow ambiguity vs the parity palette.
Include the theme-key denylist in the color-like check so call sites stop repeating OR named guards, and keep shadow-family prefixes on a known-only helper so sizes stay unambiguous.
|
| Filename | Overview |
|---|---|
| rustywind-core/src/utility_map.rs | Adds configurable named-color matching and updates color-capable utility families. |
| rustywind-core/src/app.rs | Propagates the inference setting and isolates global and prefixed sorter caches by mode. |
| rustywind-core/src/pattern_sorter.rs | Passes the configured inference mode into utility property lookup. |
| rustywind-cli/src/main.rs | Adds the named-color inference opt-out and validates incompatible sorter options. |
Reviews (2): Last reviewed commit: "Harden compare-tailwind checkout permiss..." | Re-trigger Greptile
Run just compare-tailwind on push and pull requests so ordering regressions against Prettier are caught in CI.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/compare-tailwind.yml (1)
9-33: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winPin third-party actions to immutable SHAs.
The workflow executes several external actions from mutable version tags. Pin each
uses:reference to a full commit SHA, retaining the version in a comment, to prevent tag retargeting or compromised releases from changing CI behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/compare-tailwind.yml around lines 9 - 33, Update every third-party uses reference in the workflow, including actions/checkout, actions-rust-lang/setup-rust-toolchain, actions/setup-node, extractions/setup-just, and actions/upload-artifact, to a full immutable commit SHA. Retain each action’s current version tag in an adjacent comment for traceability, without changing the workflow steps or configuration.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/compare-tailwind.yml:
- Around line 3-9: Update the compare-tailwind workflow by adding workflow-level
contents: read permissions and configuring the actions/checkout@v4 step with
persist-credentials set to false, while preserving the existing triggers and job
behavior.
---
Nitpick comments:
In @.github/workflows/compare-tailwind.yml:
- Around line 9-33: Update every third-party uses reference in the workflow,
including actions/checkout, actions-rust-lang/setup-rust-toolchain,
actions/setup-node, extractions/setup-just, and actions/upload-artifact, to a
full immutable commit SHA. Retain each action’s current version tag in an
adjacent comment for traceability, without changing the workflow steps or
configuration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f83b2823-dd97-4eaf-a38c-0be215c191f4
📒 Files selected for processing (1)
.github/workflows/compare-tailwind.yml
Default named-color inference treats ambiguous project names such as text-display as colors. Projects that use those names for other purposes can disable inference while still recognizing palette, arbitrary, and CSS-variable colors. Also resolve typed (length:...) parentheses to width/position slots for Tailwind parity.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rustywind-core/src/utility_map.rs (1)
2226-2243: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winExpand typed parenthesized hints beyond
length. Tailwind accepts other data types here (number,angle,percentage, etc.), so treating every non-lengthvalue asColormisclassifies valid classes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rustywind-core/src/utility_map.rs` around lines 2226 - 2243, Update ParenthesizedValueKind::parse so recognized typed hints such as number, angle, and percentage are classified appropriately instead of falling through to Color. Add or reuse distinct enum variants for the supported data types, while preserving Color for untyped hints and only unsupported types according to the existing contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@rustywind-core/src/utility_map.rs`:
- Around line 2226-2243: Update ParenthesizedValueKind::parse so recognized
typed hints such as number, angle, and percentage are classified appropriately
instead of falling through to Color. Add or reuse distinct enum variants for the
supported data types, while preserving Color for untyped hints and only
unsupported types according to the existing contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b558d1f6-3a19-4343-91b3-8ed3c309394b
📒 Files selected for processing (12)
CHANGELOG.mdREADME.mdrustywind-cli/src/main.rsrustywind-cli/src/options.rsrustywind-cli/tests/named_colors.rsrustywind-core/CHANGELOG.mdrustywind-core/src/app.rsrustywind-core/src/hybrid_sorter.rsrustywind-core/src/pattern_sorter.rsrustywind-core/src/utility_map.rsrustywind-core/tests/test_tailwind_prefix.rstests/tailwind-compare/README.md
Scope the workflow to contents: read and disable persisted checkout credentials for this PR job.
Summary
Classify arbitrary named design-system values such as
bg-muted,text-foreground,border-input, andbg-card/90as color utilities so they sort like Prettier instead of falling through as unknown classes.border-{t,r,b,l,x,y,s,e}-<name>) resolve to border color rather than border width--shadow-*sizesWhy
Projects that use semantic/design-system color tokens (e.g. shadcn-style palettes) currently get inconsistent sort order versus
prettier-plugin-tailwindcss. Treating those named values as known color utilities closes that gap for the common cases without misclassifying ambiguous shadow sizes.Test plan
Summary by CodeRabbit
--no-named-colorsto disable named-color inference and keep ambiguous project-defined names unchanged.@themepalette and the new flag’s behavior.