From 00df6e5ccb021f9d8e1fb73b4e256142b3df8f5c Mon Sep 17 00:00:00 2001 From: DonIsaac <22823424+DonIsaac@users.noreply.github.com> Date: Tue, 8 Oct 2024 01:27:00 +0000 Subject: [PATCH] fix(linter): friendly diagnostic messages for `no-else-return` (#6349) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Before ``` ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. ╭─[no_else_return.tsx:1:48] 1 │ function foo1() { if (true) { return x; } else { return y; } } · ───────────── ╰──── help: Replace ` else { return y; }` with ` return y; `. ``` ### After ``` ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. ╭─[no_else_return.tsx:1:31] 1 │ function foo1() { if (true) { return x; } else { return y; } } · ────┬──── ───┬── · │ ╰── Making this `else` block unnecessary. · ╰── This consequent block always returns, ╰──── help: Remove the `else` block, moving its contents outside of the `if` statement. ``` --- .../src/rules/eslint/no_else_return.rs | 67 +- .../src/snapshots/no_else_return.snap | 675 +++++++++++------- 2 files changed, 468 insertions(+), 274 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_else_return.rs b/crates/oxc_linter/src/rules/eslint/no_else_return.rs index 30188873f96bf..7b199e8740505 100644 --- a/crates/oxc_linter/src/rules/eslint/no_else_return.rs +++ b/crates/oxc_linter/src/rules/eslint/no_else_return.rs @@ -165,8 +165,13 @@ declare_oxc_lint!( conditional_fix ); -fn no_else_return_diagnostic(else_stmt: &Statement) -> OxcDiagnostic { - OxcDiagnostic::warn("Unnecessary 'else' after 'return'.").with_label(else_stmt.span()) +fn no_else_return_diagnostic(else_keyword: Span, last_return: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Unnecessary 'else' after 'return'.") + .with_labels([ + last_return.label("This consequent block always returns,"), + else_keyword.label("Making this `else` block unnecessary."), + ]) + .with_help("Remove the `else` block, moving its contents outside of the `if` statement.") } fn is_safe_from_name_collisions( @@ -201,11 +206,15 @@ fn is_safe_from_name_collisions( fn no_else_return_diagnostic_fix( ctx: &LintContext, + last_return_span: Span, else_stmt_prev: &Statement, else_stmt: &Statement, if_block_node: &AstNode, ) { - let diagnostic = no_else_return_diagnostic(else_stmt); + let prev_span = else_stmt_prev.span(); + let else_content_span = else_stmt.span(); + let else_keyword_span = Span::new(prev_span.end, else_content_span.start); + let diagnostic = no_else_return_diagnostic(else_keyword_span, last_return_span); let parent_scope_id = if_block_node.scope_id(); if !is_safe_from_name_collisions(ctx, else_stmt, parent_scope_id) { @@ -213,8 +222,6 @@ fn no_else_return_diagnostic_fix( return; } ctx.diagnostic_with_fix(diagnostic, |fixer| { - let prev_span = else_stmt_prev.span(); - let else_content_span = else_stmt.span(); let target_span = Span::new(prev_span.end, else_content_span.end); // Capture the contents of the `else` statement, removing curly braces @@ -262,35 +269,41 @@ fn left_offset_for_whitespace(ctx: &LintContext, position: u32) -> u32 { offset as u32 } -fn naive_has_return(node: &Statement) -> bool { +fn naive_has_return(node: &Statement) -> Option { match node { Statement::BlockStatement(block) => { - let Some(last_child) = block.body.last() else { - return false; - }; - matches!(last_child, Statement::ReturnStatement(_)) + let last_child = block.body.last()?; + if let Statement::ReturnStatement(r) = last_child { + Some(r.span) + } else { + None + } } - Statement::ReturnStatement(_) => true, - _ => false, + Statement::ReturnStatement(r) => Some(r.span), + _ => None, } } -fn check_for_return_or_if(node: &Statement) -> bool { +fn check_for_return_or_if(node: &Statement) -> Option { match node { - Statement::ReturnStatement(_) => true, + Statement::ReturnStatement(r) => Some(r.span), Statement::IfStatement(if_stmt) => { - let Some(alternate) = &if_stmt.alternate else { - return false; - }; - naive_has_return(alternate) && naive_has_return(&if_stmt.consequent) + let alternate = if_stmt.alternate.as_ref()?; + if let (Some(_), Some(ret_span)) = + (naive_has_return(alternate), naive_has_return(&if_stmt.consequent)) + { + Some(ret_span) + } else { + None + } } - _ => false, + _ => None, } } -fn always_returns(stmt: &Statement) -> bool { +fn always_returns(stmt: &Statement) -> Option { match stmt { - Statement::BlockStatement(block) => block.body.iter().any(check_for_return_or_if), + Statement::BlockStatement(block) => block.body.iter().find_map(check_for_return_or_if), node => check_for_return_or_if(node), } } @@ -303,8 +316,8 @@ fn check_if_with_else(ctx: &LintContext, node: &AstNode) { return; }; - if always_returns(&if_stmt.consequent) { - no_else_return_diagnostic_fix(ctx, &if_stmt.consequent, alternate, node); + if let Some(last_return_span) = always_returns(&if_stmt.consequent) { + no_else_return_diagnostic_fix(ctx, last_return_span, &if_stmt.consequent, alternate, node); } } @@ -315,16 +328,18 @@ fn check_if_without_else(ctx: &LintContext, node: &AstNode) { let mut current_node = if_stmt; let mut last_alternate; let mut last_alternate_prev; + let mut last_return_span; loop { let Some(alternate) = ¤t_node.alternate else { return; }; - if !always_returns(¤t_node.consequent) { + let Some(ret_span) = always_returns(¤t_node.consequent) else { return; - } + }; last_alternate_prev = ¤t_node.consequent; last_alternate = alternate; + last_return_span = ret_span; match alternate { Statement::IfStatement(if_stmt) => { current_node = if_stmt; @@ -333,7 +348,7 @@ fn check_if_without_else(ctx: &LintContext, node: &AstNode) { } } - no_else_return_diagnostic_fix(ctx, last_alternate_prev, last_alternate, node); + no_else_return_diagnostic_fix(ctx, last_return_span, last_alternate_prev, last_alternate, node); } impl Rule for NoElseReturn { diff --git a/crates/oxc_linter/src/snapshots/no_else_return.snap b/crates/oxc_linter/src/snapshots/no_else_return.snap index eab731d099431..5ad909557eefd 100644 --- a/crates/oxc_linter/src/snapshots/no_else_return.snap +++ b/crates/oxc_linter/src/snapshots/no_else_return.snap @@ -2,570 +2,749 @@ source: crates/oxc_linter/src/tester.rs --- ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:48] + ╭─[no_else_return.tsx:1:31] 1 │ function foo1() { if (true) { return x; } else { return y; } } - · ───────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { return y; }` with ` return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:61] + ╭─[no_else_return.tsx:1:44] 1 │ function foo2() { if (true) { var x = bar; return x; } else { var y = baz; return y; } } - · ────────────────────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { var y = baz; return y; }` with ` var y = baz; return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:44] + ╭─[no_else_return.tsx:1:29] 1 │ function foo3() { if (true) return x; else return y; } - · ───────── + · ────┬───────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else return y;` with ` return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:74] + ╭─[no_else_return.tsx:1:42] 1 │ function foo4() { if (true) { if (false) return x; else return y; } else { return z; } } - · ───────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { return z; }` with ` return z;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:57] + ╭─[no_else_return.tsx:1:42] 1 │ function foo4() { if (true) { if (false) return x; else return y; } else { return z; } } - · ───────── + · ────┬───────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else return y;` with ` return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:69] + ╭─[no_else_return.tsx:1:54] 1 │ function foo5() { if (true) { if (false) { if (true) return x; else { w = y; } } else { w = x; } } else { return z; } } - · ────────── + · ────┬───────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { w = y; }` with ` w = y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:69] + ╭─[no_else_return.tsx:1:54] 1 │ function foo6() { if (true) { if (false) { if (true) return x; else return y; } } else { return z; } } - · ───────── + · ────┬───────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else return y;` with ` return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:98] + ╭─[no_else_return.tsx:1:81] 1 │ function foo7() { if (true) { if (false) { if (true) return x; else return y; } return w; } else { return z; } } - · ───────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { return z; }` with ` return z;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:69] + ╭─[no_else_return.tsx:1:54] 1 │ function foo7() { if (true) { if (false) { if (true) return x; else return y; } return w; } else { return z; } } - · ───────── + · ────┬───────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else return y;` with ` return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:86] + ╭─[no_else_return.tsx:1:54] 1 │ function foo8() { if (true) { if (false) { if (true) return x; else return y; } else { w = x; } } else { return z; } } - · ────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { w = x; }` with ` w = x;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:69] + ╭─[no_else_return.tsx:1:54] 1 │ function foo8() { if (true) { if (false) { if (true) return x; else return y; } else { w = x; } } else { return z; } } - · ───────── + · ────┬───────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else return y;` with ` return y;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:76] + ╭─[no_else_return.tsx:1:56] 1 │ function foo9() {if (x) { return true; } else if (y) { return true; } else { notAReturn(); } } - · ───────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { notAReturn(); }` with ` notAReturn();`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:48] + ╭─[no_else_return.tsx:1:28] 1 │ function foo9a() {if (x) { return true; } else if (y) { return true; } else { notAReturn(); } } - · ────────────────────────────────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else if (y) { return true; } else { notAReturn(); }` with ` if (y) { return true; } else { notAReturn(); }`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:72] + ╭─[no_else_return.tsx:1:52] 1 │ function foo9b() {if (x) { return true; } if (y) { return true; } else { notAReturn(); } } - · ───────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { notAReturn(); }` with ` notAReturn();`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:46] + ╭─[no_else_return.tsx:1:29] 1 │ function foo10() { if (foo) return bar; else (foo).bar(); } - · ──────────── + · ─────┬────────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else (foo).bar();` with ` (foo).bar();`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo11() { if (foo) return bar - 2 │ else { [1, 2, 3].map(foo) } } - · ────────────────────── + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo11() { if (foo) return bar + · │ ─────┬──── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else { [1, 2, 3].map(foo) } } + · ╰──── Making this `else` block unnecessary. ╰──── - help: Replace ` - else { [1, 2, 3].map(foo) }` with ` - [1, 2, 3].map(foo)`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo12() { if (foo) return bar - 2 │ else { baz() } - · ───────── - 3 │ [1, 2, 3].map(foo) } + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo12() { if (foo) return bar + · │ ─────┬──── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else { baz() } + · ╰──── Making this `else` block unnecessary. + 3 │ [1, 2, 3].map(foo) } ╰──── - help: Replace ` - else { baz() }` with ` - baz()`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo13() { if (foo) return bar; - 2 │ else { [1, 2, 3].map(foo) } } - · ────────────────────── + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo13() { if (foo) return bar; + · │ ─────┬───── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else { [1, 2, 3].map(foo) } } + · ╰──── Making this `else` block unnecessary. ╰──── - help: Replace ` - else { [1, 2, 3].map(foo) }` with ` [1, 2, 3].map(foo)`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo14() { if (foo) return bar - 2 │ else { baz(); } - · ────────── - 3 │ [1, 2, 3].map(foo) } + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo14() { if (foo) return bar + · │ ─────┬──── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else { baz(); } + · ╰──── Making this `else` block unnecessary. + 3 │ [1, 2, 3].map(foo) } ╰──── - help: Replace ` - else { baz(); }` with ` - baz();`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:46] + ╭─[no_else_return.tsx:1:29] 1 │ function foo15() { if (foo) return bar; else { baz() } qaz() } - · ───────── + · ─────┬────────┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { baz() }` with ` baz()`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo16() { if (foo) return bar - 2 │ else { baz() } qaz() } - · ───────── + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo16() { if (foo) return bar + · │ ─────┬──── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else { baz() } qaz() } + · ╰──── Making this `else` block unnecessary. ╰──── - help: Replace ` - else { baz() }` with ` - baz()`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo17() { if (foo) return bar - 2 │ else { baz() } - · ───────── - 3 │ qaz() } + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo17() { if (foo) return bar + · │ ─────┬──── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else { baz() } + · ╰──── Making this `else` block unnecessary. + 3 │ qaz() } ╰──── - help: Replace ` - else { baz() }` with ` - baz()`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:2:9] - 1 │ function foo18() { if (foo) return function() {} - 2 │ else [1, 2, 3].map(bar) } - · ────────────────── + ╭─[no_else_return.tsx:1:29] + 1 │ ╭─▶ function foo18() { if (foo) return function() {} + · │ ──────────┬───────── + · │ ╰── This consequent block always returns, + 2 │ ├─▶ else [1, 2, 3].map(bar) } + · ╰──── Making this `else` block unnecessary. ╰──── - help: Replace ` - else [1, 2, 3].map(bar)` with ` - [1, 2, 3].map(bar)`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:32] 1 │ function foo19() { if (true) { return x; } else if (false) { return y; } } - · ──────────────────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else if (false) { return y; }` with ` if (false) { return y; }`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:48] + ╭─[no_else_return.tsx:1:28] 1 │ function foo20() {if (x) { return true; } else if (y) { notAReturn() } else { notAReturn(); } } - · ────────────────────────────────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else if (y) { notAReturn() } else { notAReturn(); }` with ` if (y) { notAReturn() } else { notAReturn(); }`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:43] 1 │ function foo21() { var x = true; if (x) { return x; } else if (x === false) { return false; } } - · ────────────────────────────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else if (x === false) { return false; }` with ` if (x === false) { return false; }`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { var a; if (bar) { return true; } else { var a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { var a; }` with ` var a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:67] + ╭─[no_else_return.tsx:1:47] 1 │ function foo() { if (bar) { var a; if (baz) { return true; } else { var a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { var a; }` with ` var a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { var a; if (bar) { return true; } else { var a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { var a; }` with ` var a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:67] + ╭─[no_else_return.tsx:1:47] 1 │ function foo() { if (bar) { var a; if (baz) { return true; } else { var a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { var a; }` with ` var a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { let a; if (bar) { return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:59] + ╭─[no_else_return.tsx:1:39] 1 │ class foo { bar() { let a; if (baz) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:67] + ╭─[no_else_return.tsx:1:47] 1 │ function foo() { if (bar) { let a; if (baz) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:66] + ╭─[no_else_return.tsx:1:46] 1 │ function foo() {let a; if (bar) { if (baz) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:62] + ╭─[no_else_return.tsx:1:42] 1 │ function foo() { const a = 1; if (bar) { return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:73] + ╭─[no_else_return.tsx:1:53] 1 │ function foo() { if (bar) { const a = 1; if (baz) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { let a; if (bar) { return true; } else { const a = 1 } } - · ─────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:67] + ╭─[no_else_return.tsx:1:47] 1 │ function foo() { if (bar) { let a; if (baz) { return true; } else { const a = 1; } } } - · ──────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:61] + ╭─[no_else_return.tsx:1:41] 1 │ function foo() { class a {}; if (bar) { return true; } else { const a = 1; } } - · ──────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:72] + ╭─[no_else_return.tsx:1:52] 1 │ function foo() { if (bar) { class a {}; if (baz) { return true; } else { const a = 1; } } } - · ──────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:62] + ╭─[no_else_return.tsx:1:42] 1 │ function foo() { const a = 1; if (bar) { return true; } else { class a {} } } - · ────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:73] + ╭─[no_else_return.tsx:1:53] 1 │ function foo() { if (bar) { const a = 1; if (baz) { return true; } else { class a {} } } } - · ────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { var a; if (bar) { return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { if (bar) { var a; return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let a; } while (baz) { var a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:50] + ╭─[no_else_return.tsx:1:30] 1 │ function foo(a) { if (bar) { return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:54] + ╭─[no_else_return.tsx:1:34] 1 │ function foo(a = 1) { if (bar) { return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:57] + ╭─[no_else_return.tsx:1:37] 1 │ function foo(a, b = a) { if (bar) { return true; } else { let a; } if (bar) { return true; } else { let b; }} - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:100] + ╭─[no_else_return.tsx:1:80] 1 │ function foo(a, b = a) { if (bar) { return true; } else { let a; } if (bar) { return true; } else { let b; }} - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo(...args) { if (bar) { return true; } else { let args; } } - · ───────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:68] + ╭─[no_else_return.tsx:1:48] 1 │ function foo() { try {} catch (a) { if (bar) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:79] + ╭─[no_else_return.tsx:1:59] 1 │ function foo() { try {} catch (a) { if (bar) { if (baz) { return true; } else { let a; } } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:79] + ╭─[no_else_return.tsx:1:59] 1 │ function foo() { try {} catch ({bar, a = 1}) { if (baz) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let arguments; } } - · ────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let arguments; }` with ` let arguments;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let arguments; } return arguments[0]; } - · ────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let arguments; }` with ` let arguments;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let arguments; } if (baz) { return arguments[0]; } } - · ────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let arguments; }` with ` let arguments;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let arguments; } } } - · ────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let arguments; }` with ` let arguments;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let a; } a; } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let a; } if (baz) { a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } } a; } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } if (quux) { a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:47] + ╭─[no_else_return.tsx:1:27] 1 │ function a() { if (foo) { return true; } else { let a; } a(); } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:45] + ╭─[no_else_return.tsx:1:25] 1 │ function a() { if (a) { return true; } else { let a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:44] + ╭─[no_else_return.tsx:1:27] 1 │ function a() { if (foo) { return a; } else { let a; } } - · ────────── + · ────┬──── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let a; } function baz() { a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } (() => a) } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let a; } var a; } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } var a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } var { a } = {}; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } if (quux) { var a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } } if (quux) { var a; } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:81] + ╭─[no_else_return.tsx:1:61] 1 │ function foo() { if (quux) { var a; } if (bar) { if (baz) { return true; } else { let a; } } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else { let a; } function a(){} } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (baz) { if (bar) { return true; } else { let a; } function a(){} } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } } if (quux) { function a(){} } } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:60] + ╭─[no_else_return.tsx:1:40] 1 │ function foo() { if (bar) { if (baz) { return true; } else { let a; } } function a(){} } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { let a; if (bar) { return true; } else { function a(){} } } - · ────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:56] + ╭─[no_else_return.tsx:1:36] 1 │ function foo() { var a; if (bar) { return true; } else { function a(){} } } - · ────────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:49] + ╭─[no_else_return.tsx:1:29] 1 │ function foo() { if (bar) { return true; } else function baz() {} }; - · ───────────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:32] + ╭─[no_else_return.tsx:1:12] 1 │ if (foo) { return true; } else { let a; } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── - help: Replace ` else { let a; }` with ` let a;`. + help: Remove the `else` block, moving its contents outside of the `if` statement. ⚠ eslint(no-else-return): Unnecessary 'else' after 'return'. - ╭─[no_else_return.tsx:1:39] + ╭─[no_else_return.tsx:1:19] 1 │ let a; if (foo) { return true; } else { let a; } - · ────────── + · ──────┬───── ───┬── + · │ ╰── Making this `else` block unnecessary. + · ╰── This consequent block always returns, ╰──── + help: Remove the `else` block, moving its contents outside of the `if` statement.