Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ impl Rule for NoArrayConstructor {
&new_expr.type_arguments,
false,
),
_ => {
return;
}
_ => return,
};

let Expression::Identifier(ident) = &callee else {
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/eslint/no_cond_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ impl Rule for NoCondAssign {
AstKind::Function(_)
| AstKind::ArrowFunctionExpression(_)
| AstKind::Program(_)
| AstKind::BlockStatement(_) => {
break;
}
| AstKind::BlockStatement(_) => break,
_ => {}
}
}
Expand Down
8 changes: 2 additions & 6 deletions crates/oxc_linter/src/rules/eslint/no_negated_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ impl Rule for NoNegatedCondition {
AstKind::ConditionalExpression(conditional_expr) => {
conditional_expr.test.without_parentheses()
}
_ => {
return;
}
_ => return,
};

match stmt_test {
Expand All @@ -93,9 +91,7 @@ impl Rule for NoNegatedCondition {
return;
}
}
_ => {
return;
}
_ => return,
}

ctx.diagnostic(no_negated_condition_diagnostic(stmt_test.span()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/eslint/no_self_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,15 @@ 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()) {
return false;
}
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
Expand Down
10 changes: 4 additions & 6 deletions crates/oxc_linter/src/rules/import/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
11 changes: 4 additions & 7 deletions crates/oxc_linter/src/rules/jest/no_standalone_expect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/jest/prefer_each.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ impl Rule for IframeHasTitle {
return;
}
}
JSXExpression::CallExpression(_) => {
return;
}
JSXExpression::CallExpression(_) => return,
expr @ JSXExpression::Identifier(_) => {
if !expr.is_undefined() {
return;
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 4 additions & 10 deletions crates/oxc_linter/src/rules/jsx_a11y/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/oxc/no_map_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ impl Rule for NoWrapperObjectTypes {
return;
}
}
_ => {
return;
}
_ => return,
};

if matches!(ident_name, "BigInt" | "Boolean" | "Number" | "Object" | "String" | "Symbol") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ impl Rule for NoInvalidRemoveEventListener {
return;
}
}
_ => {
return;
}
_ => return,
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/unicorn/prefer_math_trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_linter/src/rules/unicorn/prefer_string_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading