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
10 changes: 8 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_else_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ use oxc_span::{GetSpan, Span};

use crate::{AstNode, context::LintContext, rule::Rule};

#[derive(Debug, Default, Clone)]
#[derive(Debug, Clone)]
pub struct NoElseReturn {
allow_else_if: bool,
}

impl Default for NoElseReturn {
fn default() -> Self {
Self { allow_else_if: true }
}
}

declare_oxc_lint!(
/// ### What it does
///
Expand Down Expand Up @@ -332,7 +338,7 @@ fn check_if_without_else(ctx: &LintContext, node: &AstNode) {

impl Rule for NoElseReturn {
fn from_configuration(value: serde_json::Value) -> Self {
let Some(value) = value.get(0) else { return Self { allow_else_if: true } };
let Some(value) = value.get(0) else { return Self::default() };
Self {
allow_else_if: value
.get("allowElseIf")
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_linter/tests/rule_configuration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fn test_rule_default_matches_from_configuration_null() {
// 1. The Default implementation returns the same values as from_configuration(null), or
// 2. The from_configuration method is updated to return Default::default() when given null
let exceptions = [
"eslint/no-else-return",
"import/extensions",
"import/no-anonymous-default-export",
"jest/no-deprecated-functions",
Expand Down
Loading