Skip to content
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

fix(linter): useSortedClasses false positive #4199

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ematipico marked this conversation as resolved.
Show resolved Hide resolved
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}`}/>

```