diff --git a/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs b/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs index 05bb22563c42..e7b6b573d3ac 100644 --- a/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs +++ b/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs @@ -332,22 +332,18 @@ impl Rule for UseFilenamingConvention { })); } } - let suggested_filenames = allowed_cases + let mut suggested_filenames = allowed_cases .into_iter() - .filter_map(|case| { - let new_trimmed_name = case.convert(trimmed_name); - // Filter out names that have not an allowed case - if allowed_cases.contains(Case::identify(&new_trimmed_name, options.strict_case)) { - Some(file_name.replacen(trimmed_name, &new_trimmed_name, 1)) - } else { - None - } - }) - // Deduplicate suggestions - .collect::>() - .into_iter() - .collect::>() - .join("\n"); + .map(|case| case.convert(trimmed_name).into_boxed_str()) + .filter(|new_trimmed_name| allowed_cases.contains(Case::identify(new_trimmed_name, options.strict_case))) + .collect::>(); + // We sort and deduplicate the suggested names + suggested_filenames.sort(); + suggested_filenames.dedup(); + for i in 0..suggested_filenames.len() { + suggested_filenames[i] = file_name.replacen(trimmed_name, &suggested_filenames[i], 1).into_boxed_str(); + } + let suggested_filenames = suggested_filenames.join("\n"); let diagnostic = RuleDiagnostic::new( rule_category!(), None as Option,