Skip to content

Commit

Permalink
fix(linter): useSortedClasses false positive (#4199)
Browse files Browse the repository at this point in the history
Co-authored-by: Carson McManus <[email protected]>
  • Loading branch information
ematipico and dyc3 authored Oct 7, 2024
1 parent 25035f1 commit d04ab5b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

- Fix [#4190](https://github.com/biomejs/biome/issues/4190), where the rule `noMissingVarFunction` wrongly reported a variable as missing when used inside a `var()` function that was a newline. Contributed by @ematipico

- Fix [#4041](https://github.com/biomejs/biome/issues/4041). Now the rule `useSortedClasses` won't be triggered if `className` is composed only by inlined variables. Contributed by @ematipico

### Parser

#### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ impl Rule for UseSortedClasses {
let ignore_postfix = should_ignore_postfix(node);
let sorted_value =
sort_class_name(&value, &SORT_CONFIG, ignore_prefix, ignore_postfix);
if sorted_value.is_empty() {
return None;
}
if value.text() != sorted_value {
return Some(sorted_value);
}
Expand Down
5 changes: 2 additions & 3 deletions crates/biome_js_analyze/tests/quick_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use std::{ffi::OsStr, fs::read_to_string, path::Path, slice};
// use this test check if your snippet produces the diagnostics you wish, without using a snapshot
#[ignore]
#[test]
fn run_test() {
let input_file =
Path::new("tests/specs/correctness/useExhaustiveDependencies/ignoredDependencies.js");
fn quick_test() {
let input_file = Path::new("tests/specs/nursery/useSortedClasses/issue.jsx");
let file_name = input_file.file_name().and_then(OsStr::to_str).unwrap();

let (group, rule) = parse_test_path(input_file);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div className={`${test} ${test}`}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: issue_4041.jsx
---
# Input
```jsx
<div className={`${test} ${test}`}/>

```

0 comments on commit d04ab5b

Please sign in to comment.