Skip to content

Commit c2e4cf3

Browse files
committed
test(js_analyze): add spec test for negative value utilities in useSortedClasses
1 parent 4f6d892 commit c2e4cf3

File tree

3 files changed

+308
-116
lines changed

3 files changed

+308
-116
lines changed

.changeset/negative-margin-support.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
"@biomejs/biome": patch
33
---
44

5-
feat(useSortedClasses): support negative value utilities
5+
Added support for negative value utilities in [`useSortedClasses`](https://biomejs.dev/linter/rules/use-sorted-classes/). Negative value utilities such as `-ml-2` or `-top-4` are now recognized and sorted correctly alongside their positive counterparts.
6+
7+
```jsx
8+
// Now detected as unsorted:
9+
<div class="-ml-2 p-4 -mt-1" />
10+
// Suggested fix:
11+
<div class="-mt-1 -ml-2 p-4" />
12+
```

crates/biome_js_analyze/tests/specs/nursery/useSortedClasses/unsorted.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
<div class="text-black [&nth-child(2)]:focus:text-red-100 [&nth-child(1)]:group-first:text-red-100 [&nth-child(2)]:hover:focus:bg-red-900 group-first:text-yellow-400 [&nth-child(2)]:text-black focus:bg-sky-100 py-4 checked:visited:bg-yellow-300 hover:text-red-400" />
3131
<div class="group-aria-disabled:bg-red-50 group-[:visited]:text-red-400 group-target:font-bold" />
3232
<div class="group-has-[.custom-class]:focus:underline aria-[sort=ascending]:bg-red-300 group-aria-[sort=ascending]:text-yellow-200 has-[:checked]:focus:bg-yellow-300 text-red-400" />
33+
{/* negative value utilities */}
34+
{/* SHOULD emit diagnostics (negative values like -ml-2 should be detected) */}
35+
<div class="-ml-2 p-4 -mt-1" />
36+
<div class="-mr-4 m-2 -mb-3" />
37+
<div class="text-center -mx-2 bg-blue-500 -my-4" />
38+
<div class="-top-2 absolute -left-4 right-0" />
39+
<div class="-space-x-2 flex -space-y-4 items-center" />
40+
<div class="hover:-ml-2 p-4 focus:-mt-1" />
41+
<div class="sm:-mx-4 lg:-my-2 md:p-2" />
3342
</>;
3443

3544
// functions

0 commit comments

Comments
 (0)