-
-
Notifications
You must be signed in to change notification settings - Fork 714
fix(useSortedClasses): recognize negative placement utilities #7408
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
base: main
Are you sure you want to change the base?
Conversation
|
WalkthroughThe pull request augments the Tailwind utilities whitelist used by the useSortedClasses rule by inserting nine negative placement variants: -inset-, -inset-x-, -inset-y-, -start-, -end-, -top-, -right-, -bottom-, -left-. These are added alongside their positive counterparts in crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs. Consequently, the UTILITIES_LAYER_CLASSES constant size increases from 578 to 587. No other logic or control flow changes are introduced. Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNone found. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs (1)
21-38
: Nice fix: negative placement utilities now recognisedAdding
-inset-
,-start-
,-end-
,-top-
,-right-
,-bottom-
,-left-
(and x/y variants) should stop them being misclassified and bubbled to the front. Please confirm the sort order matches expectations (e.g. shouldleft-*
come before or after-left-*
when otherwise equal?) and add a test case for something like:class="container top-0 -left-2 left-1"
.Would you like me to draft a couple of
useSortedClasses
tests covering negative placement (and a quick audit for other negative-able groups like transforms)?
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Format Rust and TOML files before committing (use
just f
/just format
).
Files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
🧠 Learnings (1)
📚 Learning: 2025-09-05T09:13:58.901Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-05T09:13:58.901Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/**/*.rs : Place all new rules in the nursery group under biome_js_analyze/lib/src/lint/nursery
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
const COMPONENTS_LAYER_CLASSES: [&str; 1] = ["container$"]; | ||
|
||
const UTILITIES_LAYER_CLASSES: [&str; 578] = [ | ||
const UTILITIES_LAYER_CLASSES: [&str; 587] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Edit the generator, not the generated file
This file is explicitly autogen. Please move the change into packages/@biomejs/tailwindcss-config-analyzer
and re-run pnpm gen:tailwind-preset
so the update is durable and won’t be clobbered on the next regen. Also run repo formatters before commit.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE=crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
# Sanity-check that all negative placement tokens are present
rg -n '"-inset-"|"-inset-x-"|"-inset-y-"|"-start-"|"-end-"|"-top-"|"-right-"|"-bottom-"|"-left-"' "$FILE"
# Regenerate from source and show any drift
pnpm -w gen:tailwind-preset
git --no-pager diff -- "$FILE" || true
# Optional: format
just f || just format || true
Length of output: 563
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Confirm file header to verify autogenerated notice
sed -n '1,20p' crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
# Locate the generator package directory
fd -t d tailwindcss-config-analyzer
# Check for gen:tailwind-preset script in root package.json
rg -n 'gen:tailwind-preset' package.json || echo "No root gen:tailwind-preset script found"
# Check for gen:tailwind-preset script in generator's package.json
if [ -f packages/@biomejs/tailwindcss-config-analyzer/package.json ]; then
rg -n 'gen:tailwind-preset' packages/@biomejs/tailwindcss-config-analyzer/package.json || echo "No gen:tailwind-preset script in generator"
fi
Length of output: 954
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify the generator package exists and list its scripts
if [ -f packages/tailwindcss-config-analyzer/package.json ]; then
echo "Found generator package.json at packages/tailwindcss-config-analyzer/package.json"
rg -n '"gen:tailwind-preset"' packages/tailwindcss-config-analyzer/package.json || echo "gen:tailwind-preset script missing"
else
echo "Generator package.json not found"
fi
Length of output: 416
Add missing gen:tailwind-preset script and regenerate Tailwind preset
The file crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
is autogenerated—apply your change in packages/tailwindcss-config-analyzer
, add a gen:tailwind-preset
script to its package.json
, run pnpm gen:tailwind-preset
, commit the regenerated file, then run the repo’s formatters.
🤖 Prompt for AI Agents
In
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
around line 8, the autogenerated Tailwind preset file is out-of-date; you must
not edit this file directly. Instead, open packages/tailwindcss-config-analyzer,
add a "gen:tailwind-preset" script to its package.json that runs the generator
(e.g., node or pnpm command used by the package), run pnpm gen:tailwind-preset
to regenerate the preset, commit the updated tailwind_preset.rs into the crate,
and run the repository formatters (pnpm -w prettier/rustfmt or the repo-specific
format commands) before pushing.
Neither pnpm nor I can find the
And execution doesn't work either, fails with |
It's really an old command, initially built with bun too. It hasn't been run since it was created, so a long time. I'm not sure how it works either, so it's possible it's broken and it requires fixing. |
Changeset: you must add it yourself, here's how: https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#create-a-changeset Tests: you must add new tests here https://github.com/biomejs/biome/tree/main/crates/biome_js_analyze/tests/specs/nursery/useSortedClasses |
CodSpeed Performance ReportMerging #7408 will not alter performanceComparing Summary
|
Summary
Fixes #7407 by adding negative versions of placement utilities (e.g.
-end
) to the list of Tailwind utilities.Changeset: Biome now recognizes negative placement utilities such as
-inset-px
or-end-full
. This means that it'll no longer put them at the start of the class list.Test Plan
?