feat(natu): detect single-use let bindings

This commit is contained in:
2026-09-30 10:41:42 -04:00
parent 2265dfc558
commit 852b14cff0
8 changed files with 154 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ pub mod list_to_attrs_map;
pub mod manual_inherit;
pub mod manual_inherit_from;
pub mod redundant_parameter_forwarding;
pub mod single_use_binding;
pub mod unquoted_uri;
#[derive(Debug)]
@@ -100,11 +101,22 @@ pub fn run_rules(file: &ast::ParsedFile, graph: &ScopeGraph, source: &str) -> Ve
binding: None,
expected_order: None,
});
let single_use_binding_diagnostics =
single_use_binding::check(graph)
.into_iter()
.map(|finding| Finding {
rule_id: "single_use_binding",
range: finding.range,
message: "Inline this single-use let binding",
binding: Some(finding.name),
expected_order: None,
});
node_diagnostics
.chain(token_diagnostics)
.chain(let_order_diagnostics)
.chain(redundant_parameter_forwarding_diagnostics)
.chain(single_use_binding_diagnostics)
.filter(|finding| !is_suppressed(source, finding.range, finding.rule_id))
.map(|finding| Diagnostic {
file_id: file.file_id,