-
-
Notifications
You must be signed in to change notification settings - Fork 781
feat(useSortedClasses): add support for negative value utilities #8297
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
feat(useSortedClasses): add support for negative value utilities #8297
Conversation
🦋 Changeset detectedLatest commit: c2e4cf3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
dyc3
left a comment
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.
No complaints here. LGTM!
WalkthroughThis pull request extends the Suggested labels
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (2)**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
.changeset/**/*.md📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (14)📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.371ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-24T18:05:42.356ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-27T23:04:02.022ZApplied to files:
📚 Learning: 2025-11-28T09:08:10.077ZApplied to files:
🔇 Additional comments (5)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
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: 0
🧹 Nitpick comments (1)
.changeset/negative-margin-support.md (1)
5-5: Consider enhancing the changeset description with an example.Whilst the description is concise, adding a brief code example would help users understand the feature. Consider something like:
-feat(useSortedClasses): support negative value utilities +The `useSortedClasses` rule now correctly sorts negative value utilities (e.g., `-ml-2`, `-space-x-4`) alongside their positive counterparts.Based on coding guidelines requiring code examples for rule changes, though this is more of an enhancement than a new rule.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/negative-margin-support.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs(5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Format Rust and TOML files using
just formatbefore committing
Files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use the
dbg!()macro for debugging in Rust code, and run tests with--show-outputflag to see debug output
Files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: Write changeset descriptions that are concise, use past tense for actions, use present tense for Biome behavior, and include code examples for new rules and formatter changes
Use only####or#####headers in changeset descriptions to avoid breaking the CHANGELOG and upstream tools
Files:
.changeset/negative-margin-support.md
🧠 Learnings (10)
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUseless` prefix for rules that report unnecessary code that could be removed or simplified (e.g., `noUselessConstructor`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T15:53:30.831Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T15:53:30.831Z
Learning: Applies to **/crates/biome_analyze/**/*.rs : Update inline rustdoc documentation for rules, assists, and their options when implementing new features or changes
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noMisleading` prefix for rules that report valid but potentially misleading code (e.g., `noMisleadingCharacterClass`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnused` prefix for rules that report unused entities (e.g., `noUnusedVariables`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noConstant` prefix for rules that report computations always evaluated to the same value (e.g., `noConstantMathMinMaxClamp`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : New rules must be placed inside the `nursery` group as an incubation space exempt from semantic versioning, with promotion to appropriate groups done during minor/major releases
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: End-to-end tests
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: autofix
- GitHub Check: Validate rules documentation
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
🔇 Additional comments (4)
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/class_info.rs (4)
41-44: Elegant solution for negative value support.The symmetric hyphen-stripping approach cleanly handles both negative utilities (
-ml-2) and negative targets (-ml-) whilst preserving the existing matching logic. Well done.
70-71: Good test coverage for negative value edge cases.The additions to existing tests appropriately verify that negative utilities match their targets in both exact and partial scenarios.
Also applies to: 88-89, 100-101
105-167: Thorough test coverage for negative utilities.Excellent coverage across margins, spacing, and positioning utilities, plus edge cases for negative targets. The test organisation is clear and assertions are appropriate.
742-838: Comprehensive integration test validates the feature end-to-end.The test properly verifies that negative utilities are classified with the correct layer and utility indices, including interaction with variants. Nice inclusion of the sanity check that positive values remain unaffected.
ematipico
left a comment
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.
I believe this PR isn't ready. Here's why:
- The changeset is poorly written. We recently revamped that section, you should take a look
- There aren't any rule tests e.g. new files that emit the proper rule diagnostics shown to the user. Can we have at least one?
| "@biomejs/biome": patch | ||
| --- | ||
|
|
||
| feat(useSortedClasses): support negative value utilities |
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.
Could we improve the changeset, please? For example, you're shipping this as a fix, but then the test uses "feat".
Please use our contribution guide to understand how to write a changeset.
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
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (2)
.changeset/negative-margin-support.md(1 hunks)crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md: Create changesets for user-facing changes usingjust new-changeset; use headers with####or#####only; keep descriptions concise (1-3 sentences) and focus on user-facing changes
Use past tense when describing what was done ('Added new feature'), present tense when describing Biome behavior ('Biome now supports'); end sentences with a full stop
For new lint rules, show an example of an invalid case in an inline code snippet or code block; for rule changes, demonstrate what is now invalid or valid; for formatter changes, use adiffcode block
Files:
.changeset/negative-margin-support.md
🧠 Learnings (5)
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.{js,ts,tsx,jsx,json,css} : Test rules using snapshot tests via the `insta` library with test cases in `tests/specs/<group>/<rule_name>/` directories prefixed by `invalid` or `valid`
Applied to files:
crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.jsonc : Use `.jsonc` files in test specs with code snippets as array of strings to test rules in script environment (no import/export syntax)
Applied to files:
crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`
Applied to files:
crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/specs/**/options.json : Create an `options.json` file (formatted as `biome.json`) in test specification folders to apply non-default formatting options to all test files in that folder
Applied to files:
crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx
📚 Learning: 2025-11-28T09:08:10.077Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.077Z
Learning: Applies to .changeset/**/*.md : Create changesets for user-facing changes using `just new-changeset`; use headers with `####` or `#####` only; keep descriptions concise (1-3 sentences) and focus on user-facing changes
Applied to files:
.changeset/negative-margin-support.md
🔇 Additional comments (1)
.changeset/negative-margin-support.md (1)
1-12: Changeset clearly describes the user‑visible rule change and matches the style guide.Patch type, tense, and the invalid→fix example for
useSortedClassesall look good here; nothing to change from my side. As per coding guidelines, this is concise, user‑facing, and well scoped.
crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/negativeValues.jsx
Outdated
Show resolved
Hide resolved
…dClasses The useSortedClasses rule now correctly detects and sorts negative value utilities like -ml-2, -mr-4, -top-2, etc. The fix strips the leading hyphen before matching utilities against their targets, allowing negative variants to be recognized and sorted alongside their positive counterparts.
This allows custom utilities defined with a leading `-` prefix to be matched when the target is specified with a `-` prefix (e.g., `-test$` matches `-test`).
The rule now detects and sorts negative value utilities like '-ml-2', '-mr-4', and allows custom utilities with a leading '-' prefix to be matched.
a798216 to
c2e4cf3
Compare
CodSpeed Performance ReportMerging #8297 will not alter performanceComparing Summary
Footnotes
|
This PR was written primarily by Claude Code.
Summary
The useSortedClasses rule now detects and sorts negative value utilities like -ml-2, -mr-4, -top-2, etc. The fix strips the leading hyphen before matching utilities against their targets, allowing negative variants to be recognized and sorted alongside their positive counterparts.
The codebase featured
// TODO: support negative values. This is now solved.Test Plan
Docs
None