From 06f44a3a19bbd2fe0acc22f9766620c5f8545e96 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 8 Sep 2025 04:36:26 +0000 Subject: [PATCH] refactor(linter_codegen): simplify sorting rules (#13575) Follow-on after #13138, as per [this comment](https://github.com/oxc-project/oxc/pull/13138#discussion_r2328541818). Pure refactor. Simplify sorting rules, by leaning on derived traits instead of manual implementation. --- tasks/linter_codegen/src/main.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tasks/linter_codegen/src/main.rs b/tasks/linter_codegen/src/main.rs index 605d44e367fee..bcc0f4f27daf3 100644 --- a/tasks/linter_codegen/src/main.rs +++ b/tasks/linter_codegen/src/main.rs @@ -93,6 +93,7 @@ fn find_rule_source_file(root: &Path, rule: &RuleEntry) -> Option { /// The module name of the rule's plugin, like `eslint` in `eslint::no_debugger::NoDebugger`. plugin_module_name: &'e str, @@ -141,14 +142,7 @@ fn get_all_rules(contents: &str) -> io::Result>> { rule_entries.push(RuleEntry { plugin_module_name, rule_module_name }); } // Sort deterministically - rule_entries.sort_by(|a, b| { - let ord = a.plugin_module_name.cmp(b.plugin_module_name); - if ord == std::cmp::Ordering::Equal { - a.rule_module_name.cmp(b.rule_module_name) - } else { - ord - } - }); + rule_entries.sort_unstable(); Ok(rule_entries) }