diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs index 1a51b5a7ca9e3..4da03cda5bd6c 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs @@ -70,7 +70,7 @@ impl NoUnusedVars { } // check if res is an array/object unpacking pattern that should be ignored - matches!(decl.id.check_unused_binding_pattern(&*self, symbol), Some(res) if res.is_ignore()) + matches!(decl.id.check_unused_binding_pattern(self, symbol), Some(res) if res.is_ignore()) } pub(super) fn is_allowed_argument<'a>( @@ -104,7 +104,7 @@ impl NoUnusedVars { // arguments inside setters are allowed // (1 to skip self, then the next should be a function or method) = 2 let maybe_method_or_fn = - semantic.nodes().iter_parents(params_id).nth(2).map(|node| node.kind()); + semantic.nodes().iter_parents(params_id).nth(2).map(oxc_semantic::AstNode::kind); if matches!( maybe_method_or_fn, Some( @@ -131,7 +131,10 @@ impl NoUnusedVars { // check if this is a positional argument - unused non-positional // arguments are never allowed if param.pattern.kind.is_destructuring_pattern() { - return false; + // allow unpacked parameters that are ignored + let maybe_unused_binding_pattern = + param.pattern.check_unused_binding_pattern(self, symbol); + return maybe_unused_binding_pattern.map_or(false, |res| res.is_ignore()); } // find the index of the parameter in the parameters list. We want to diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs index c10b7199b618c..da5911a364f17 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/binding_pattern.rs @@ -107,8 +107,7 @@ impl<'a> CheckBinding<'a> for ObjectPattern<'a> { return self .rest .as_ref() - .map(|rest| rest.check_unused_binding_pattern(options, symbol)) - .flatten(); + .and_then(|rest| rest.check_unused_binding_pattern(options, symbol)); } } @@ -150,7 +149,7 @@ impl<'a> CheckBinding<'a> for ArrayPattern<'a> { .destructured_array_ignore_pattern .as_ref() .is_some_and(|pattern| pattern.is_match(symbol.name())); - return res | is_ignorable; + res | is_ignorable }); if res.is_some() { diff --git a/crates/oxc_linter/src/tester.rs b/crates/oxc_linter/src/tester.rs index c3c632a1edd48..bf0d8d69797a9 100644 --- a/crates/oxc_linter/src/tester.rs +++ b/crates/oxc_linter/src/tester.rs @@ -227,7 +227,7 @@ impl Tester { settings.bind(|| { insta::assert_snapshot!(name, self.snapshot); - }) + }); } fn test_pass(&mut self) {