diff --git a/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs index fc9c290a8d3b2..d63f87df8ebae 100644 --- a/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_array_constructor.rs @@ -68,9 +68,7 @@ impl Rule for NoArrayConstructor { &new_expr.type_arguments, false, ), - _ => { - return; - } + _ => return, }; let Expression::Identifier(ident) = &callee else { diff --git a/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs b/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs index 4408c97130fec..7142fa0816fe9 100644 --- a/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_cond_assign.rs @@ -111,9 +111,7 @@ impl Rule for NoCondAssign { AstKind::Function(_) | AstKind::ArrowFunctionExpression(_) | AstKind::Program(_) - | AstKind::BlockStatement(_) => { - break; - } + | AstKind::BlockStatement(_) => break, _ => {} } } diff --git a/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs b/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs index 179206d376c35..898e25921b41b 100644 --- a/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs +++ b/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs @@ -74,9 +74,7 @@ impl Rule for NoNegatedCondition { AstKind::ConditionalExpression(conditional_expr) => { conditional_expr.test.without_parentheses() } - _ => { - return; - } + _ => return, }; match stmt_test { @@ -93,9 +91,7 @@ impl Rule for NoNegatedCondition { return; } } - _ => { - return; - } + _ => return, } ctx.diagnostic(no_negated_condition_diagnostic(stmt_test.span())); diff --git a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs index 4f85dc47db4ad..31f42484fd9a2 100644 --- a/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs +++ b/crates/oxc_linter/src/rules/eslint/no_object_constructor.rs @@ -53,9 +53,7 @@ impl Rule for NoObjectConstructor { AstKind::NewExpression(new_expr) => { (new_expr.span, &new_expr.callee, &new_expr.arguments, &new_expr.type_arguments) } - _ => { - return; - } + _ => return, }; let Expression::Identifier(ident) = &callee else { diff --git a/crates/oxc_linter/src/rules/eslint/no_self_assign.rs b/crates/oxc_linter/src/rules/eslint/no_self_assign.rs index 217954af92a62..f09c0a981e8dc 100644 --- a/crates/oxc_linter/src/rules/eslint/no_self_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_self_assign.rs @@ -312,9 +312,7 @@ impl NoSelfAssign { binding @ match_assignment_target!(AssignmentTargetMaybeDefault) => { binding.to_assignment_target() } - AssignmentTargetMaybeDefault::AssignmentTargetWithDefault(_) => { - return; - } + AssignmentTargetMaybeDefault::AssignmentTargetWithDefault(_) => return, }; let ObjectPropertyKind::ObjectProperty(obj_prop) = right else { return; diff --git a/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs b/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs index 231e8594d2fe1..8d4c3131e0075 100644 --- a/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs +++ b/crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs @@ -497,9 +497,7 @@ impl<'a> Symbol<'_, 'a> { // loops? AstKind::ForInStatement(_) | AstKind::ForOfStatement(_) - | AstKind::WhileStatement(_) => { - break; - } + | AstKind::WhileStatement(_) => break, // this is needed to handle `return () => foo++` AstKind::ExpressionStatement(_) => { if self.is_in_return_statement(node.id()) { @@ -507,9 +505,7 @@ impl<'a> Symbol<'_, 'a> { } break; } - AstKind::Function(f) if f.is_declaration() => { - break; - } + AstKind::Function(f) if f.is_declaration() => break, // implicit return in an arrow function AstKind::ArrowFunctionExpression(f) if f.body.statements.len() == 1 diff --git a/crates/oxc_linter/src/rules/import/namespace.rs b/crates/oxc_linter/src/rules/import/namespace.rs index 38b9126fbcb3c..ca8a4b5c72d47 100644 --- a/crates/oxc_linter/src/rules/import/namespace.rs +++ b/crates/oxc_linter/src/rules/import/namespace.rs @@ -130,12 +130,10 @@ impl Rule for Namespace { let (source, module) = match &entry.import_name { ImportImportName::NamespaceObject => { let source = entry.module_request.name(); - match loaded_modules.get(source) { - Some(module) => (source.to_string(), Arc::clone(module)), - _ => { - return; - } - } + let Some(module) = loaded_modules.get(source) else { + return; + }; + (source.to_string(), Arc::clone(module)) } ImportImportName::Name(name) => { let Some(loaded_module) = loaded_modules.get(entry.module_request.name()) diff --git a/crates/oxc_linter/src/rules/jest/no_standalone_expect/mod.rs b/crates/oxc_linter/src/rules/jest/no_standalone_expect/mod.rs index c0bbf78d56ff7..1e7193e0b6517 100644 --- a/crates/oxc_linter/src/rules/jest/no_standalone_expect/mod.rs +++ b/crates/oxc_linter/src/rules/jest/no_standalone_expect/mod.rs @@ -137,14 +137,11 @@ fn is_correct_place_to_call_expect<'a>( // loop until find the closest function body loop { - match parent.kind() { - AstKind::FunctionBody(_) => { - break; - } - _ => { - parent = ctx.nodes().parent_node(parent.id())?; - } + if matches!(parent.kind(), AstKind::FunctionBody(_)) { + break; } + + parent = ctx.nodes().parent_node(parent.id())?; } let node = parent; diff --git a/crates/oxc_linter/src/rules/jest/prefer_each.rs b/crates/oxc_linter/src/rules/jest/prefer_each.rs index b1c34fce77a47..ce6ae510a3e51 100644 --- a/crates/oxc_linter/src/rules/jest/prefer_each.rs +++ b/crates/oxc_linter/src/rules/jest/prefer_each.rs @@ -100,9 +100,7 @@ impl PreferEach { for parent_node in ctx.nodes().ancestors(node.id()).skip(1) { match parent_node.kind() { - AstKind::CallExpression(_) => { - return; - } + AstKind::CallExpression(_) => return, AstKind::ForStatement(_) | AstKind::ForInStatement(_) | AstKind::ForOfStatement(_) => { diff --git a/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs b/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs index 43e876dbbcd5b..b94cbf521cac4 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs @@ -98,9 +98,7 @@ impl Rule for IframeHasTitle { return; } } - JSXExpression::CallExpression(_) => { - return; - } + JSXExpression::CallExpression(_) => return, expr @ JSXExpression::Identifier(_) => { if !expr.is_undefined() { return; diff --git a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs index 25c1d2c1d5569..2685c14f0067c 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs @@ -147,9 +147,7 @@ impl Rule for ImgRedundantAlt { let alt_attribute_name = match alt_prop { JSXAttributeItem::Attribute(attr) => &attr.name, - JSXAttributeItem::SpreadAttribute(_) => { - return; - } + JSXAttributeItem::SpreadAttribute(_) => return, }; let alt_attribute_name_span = match alt_attribute_name { diff --git a/crates/oxc_linter/src/rules/jsx_a11y/scope.rs b/crates/oxc_linter/src/rules/jsx_a11y/scope.rs index cbc45ea71d5a5..92eb2428c3fbb 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/scope.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/scope.rs @@ -55,16 +55,10 @@ impl Rule for Scope { return; }; - let scope_attribute = match has_jsx_prop_ignore_case(jsx_el, "scope") { - Some(v) => match v { - JSXAttributeItem::Attribute(attr) => attr, - JSXAttributeItem::SpreadAttribute(_) => { - return; - } - }, - None => { - return; - } + let Some(JSXAttributeItem::Attribute(scope_attribute)) = + has_jsx_prop_ignore_case(jsx_el, "scope") + else { + return; }; let element_type = get_element_type(ctx, jsx_el); diff --git a/crates/oxc_linter/src/rules/oxc/no_map_spread.rs b/crates/oxc_linter/src/rules/oxc/no_map_spread.rs index 65ae71e4a83ac..463794711b43c 100644 --- a/crates/oxc_linter/src/rules/oxc/no_map_spread.rs +++ b/crates/oxc_linter/src/rules/oxc/no_map_spread.rs @@ -365,9 +365,7 @@ impl Rule for NoMapSpread { } // Mapped class properties likely have their elements spread to // avoid side effects on the class instance. - Err(Expression::ThisExpression(_)) => { - return; - } + Err(Expression::ThisExpression(_)) => return, Err(_) => {} } diff --git a/crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs b/crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs index f7bca50311831..001a0c577e489 100644 --- a/crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs +++ b/crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs @@ -79,9 +79,7 @@ impl Rule for NoWrapperObjectTypes { return; } } - _ => { - return; - } + _ => return, }; if matches!(ident_name, "BigInt" | "Boolean" | "Number" | "Object" | "String" | "Symbol") { diff --git a/crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs b/crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs index e313bedeabaf0..ab1d6942627fb 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_accessor_recursion.rs @@ -219,9 +219,7 @@ fn get_nearest_function<'a>(node: &AstNode, ctx: &'a LintContext) -> Option<&'a let mut parent = ctx.nodes().parent_node(node.id())?; while let Some(new_parent) = ctx.nodes().parent_node(parent.id()) { match parent.kind() { - AstKind::Function(_) => { - break; - } + AstKind::Function(_) => break, // If a class is declared in the accessor, ignore it // e.g. "let foo = { get bar() { class baz { } } }" AstKind::Class(_) => { diff --git a/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs b/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs index 0c33dd5a7fcef..55373b1282162 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs @@ -99,9 +99,7 @@ impl Rule for NoInvalidRemoveEventListener { return; } } - _ => { - return; - } + _ => return, } } diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_math_trunc.rs b/crates/oxc_linter/src/rules/unicorn/prefer_math_trunc.rs index 29fc99614bd97..1c6a90ac20298 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_math_trunc.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_math_trunc.rs @@ -113,9 +113,7 @@ impl Rule for PreferMathTrunc { assignment_expr.operator.as_str() } - _ => { - return; - } + _ => return, }; ctx.diagnostic(prefer_math_trunc_diagnostic(node.kind().span(), operator)); diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_string_raw.rs b/crates/oxc_linter/src/rules/unicorn/prefer_string_raw.rs index c176c98d7a4b9..da79b5f2ad1f5 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_string_raw.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_string_raw.rs @@ -77,9 +77,7 @@ impl Rule for PreferStringRaw { if let Some(parent_node) = parent_node { match parent_node.kind() { - AstKind::Directive(_) => { - return; - } + AstKind::Directive(_) => return, AstKind::ImportDeclaration(decl) => { if string_literal.span == decl.source.span { return;