Skip to content
Closed
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
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/biome_js_analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ biome_rowan = { workspace = true }
biome_rule_options = { workspace = true }
biome_string_case = { workspace = true, features = ["biome_rowan"] }
biome_suppression = { workspace = true }
biome_tailwind_sort = { path = "../biome_tailwind_sort" }
biome_unicode_table = { workspace = true }
bitvec = "1.0.1"
camino = { workspace = true }
enumflags2 = { workspace = true }
globset = { workspace = true }
Expand All @@ -61,6 +61,7 @@ biome_fs = { workspace = true }
biome_js_parser = { path = "../biome_js_parser", features = ["tests"] }
biome_plugin_loader = { workspace = true }
biome_service = { workspace = true }
biome_tailwind_sort = { path = "../biome_tailwind_sort" }
biome_test_utils = { path = "../biome_test_utils" }
criterion = { package = "codspeed-criterion-compat", version = "*" }
insta = { workspace = true, features = ["glob"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use biome_js_analyze::lint::nursery::use_sorted_classes::class_lexer::tokenize_class;
use biome_tailwind_sort::class_lexer::tokenize_class;
use criterion::{BenchmarkId, Criterion, Throughput, black_box, criterion_group, criterion_main};

#[cfg(target_os = "windows")]
Expand Down
17 changes: 5 additions & 12 deletions crates/biome_js_analyze/src/lint/nursery/use_sorted_classes.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
mod class_info;
pub mod class_lexer;
mod presets;
mod sort;
mod sort_config;
mod tailwind_preset;

use self::{
presets::UseSortedClassesPreset, sort::get_sort_class_name_range, sort::sort_class_name,
sort_config::SortConfig,
};
use self::sort::{get_sort_class_name_range, get_template_literal_space_context, sort_class_name};
use crate::JsRuleAction;
use crate::shared::any_class_string_like::AnyClassStringLike;
use biome_analyze::{Ast, FixKind, Rule, RuleDiagnostic, context::RuleContext, declare_lint_rule};
Expand All @@ -19,7 +11,8 @@ use biome_js_factory::make::{
};
use biome_rowan::{AstNode, BatchMutationExt};
use biome_rule_options::use_sorted_classes::UseSortedClassesOptions;
use presets::get_config_preset;
use biome_tailwind_sort::presets::{UseSortedClassesPreset, get_config_preset};
use biome_tailwind_sort::sort_config::SortConfig;
use std::sync::LazyLock;

declare_lint_rule! {
Expand Down Expand Up @@ -176,7 +169,7 @@ impl Rule for UseSortedClasses {
if node.should_visit(options)?
&& let Some(value) = node.value()
{
let template_ctx = sort::get_template_literal_space_context(node);
let template_ctx = get_template_literal_space_context(node);
let sorted_value: String = sort_class_name(&value, &SORT_CONFIG, &template_ctx);
if sorted_value.is_empty() {
return None;
Expand All @@ -194,7 +187,7 @@ impl Rule for UseSortedClasses {
// Calculate the range offset to account for the ignored prefix and postfix.
let sort_range = if let Some(value) = node.value() {
let range = node.range();
let template_ctx = sort::get_template_literal_space_context(node);
let template_ctx = get_template_literal_space_context(node);
let real_sort_range = get_sort_class_name_range(&value, &range, &template_ctx);
real_sort_range.unwrap_or(range)
} else {
Expand Down
Loading