Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linter): friendly diagnostic messages for no-else-return #6349

Commits on Oct 8, 2024

  1. fix(linter): friendly diagnostic messages for no-else-return (#6349)

    ### 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.
    ```
    DonIsaac committed Oct 8, 2024
    Configuration menu
    Copy the full SHA
    00df6e5 View commit details
    Browse the repository at this point in the history