Skip to content

Commit 42c8f29

Browse files
committed
fix(linter): default options for eslint/no-else-return (#12762)
https://eslint.org/docs/latest/rules/no-else-return#options
1 parent 4eac511 commit 42c8f29

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

crates/oxc_linter/src/rules/eslint/no_else_return.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ use oxc_span::{GetSpan, Span};
66

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

9-
#[derive(Debug, Default, Clone)]
9+
#[derive(Debug, Clone)]
1010
pub struct NoElseReturn {
1111
allow_else_if: bool,
1212
}
1313

14+
impl Default for NoElseReturn {
15+
fn default() -> Self {
16+
Self { allow_else_if: true }
17+
}
18+
}
19+
1420
declare_oxc_lint!(
1521
/// ### What it does
1622
///
@@ -332,7 +338,7 @@ fn check_if_without_else(ctx: &LintContext, node: &AstNode) {
332338

333339
impl Rule for NoElseReturn {
334340
fn from_configuration(value: serde_json::Value) -> Self {
335-
let Some(value) = value.get(0) else { return Self { allow_else_if: true } };
341+
let Some(value) = value.get(0) else { return Self::default() };
336342
Self {
337343
allow_else_if: value
338344
.get("allowElseIf")

crates/oxc_linter/tests/rule_configuration_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fn test_rule_default_matches_from_configuration_null() {
2525
// 1. The Default implementation returns the same values as from_configuration(null), or
2626
// 2. The from_configuration method is updated to return Default::default() when given null
2727
let exceptions = [
28-
"eslint/no-else-return",
2928
"import/extensions",
3029
"import/no-anonymous-default-export",
3130
"jest/no-deprecated-functions",

0 commit comments

Comments
 (0)