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

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Oct 7, 2024

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.

Copy link
Contributor Author

DonIsaac commented Oct 7, 2024

@github-actions github-actions bot added the A-linter Area - Linter label Oct 7, 2024
@DonIsaac DonIsaac added the C-enhancement Category - New feature or request label Oct 7, 2024 — with Graphite App
@DonIsaac DonIsaac marked this pull request as ready for review October 7, 2024 19:00
Copy link

codspeed-hq bot commented Oct 7, 2024

CodSpeed Performance Report

Merging #6349 will not alter performance

Comparing don/10-07-fix_linter_friendly_diagnostic_messages_for_no-else-return_ (63f1622) with main (71ad5d3)

Summary

✅ 29 untouched benchmarks

@DonIsaac DonIsaac changed the base branch from don/10-07-fix_linter_no_else_return_fixer_fails_when_else_has_no_trailing_whitespace to graphite-base/6349 October 7, 2024 23:19
@DonIsaac DonIsaac force-pushed the don/10-07-fix_linter_friendly_diagnostic_messages_for_no-else-return_ branch from 40f966f to 9991923 Compare October 7, 2024 23:24
@DonIsaac DonIsaac changed the base branch from graphite-base/6349 to main October 7, 2024 23:25
@DonIsaac DonIsaac force-pushed the don/10-07-fix_linter_friendly_diagnostic_messages_for_no-else-return_ branch from 9991923 to 63f1622 Compare October 7, 2024 23:25
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Oct 8, 2024
Copy link

graphite-app bot commented Oct 8, 2024

Merge activity

  • Oct 7, 9:26 PM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 7, 9:26 PM EDT: Boshen added this pull request to the Graphite merge queue.
  • Oct 7, 9:31 PM EDT: Boshen merged this pull request with the Graphite merge queue.

### 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.
```
@Boshen Boshen force-pushed the don/10-07-fix_linter_friendly_diagnostic_messages_for_no-else-return_ branch from 63f1622 to 00df6e5 Compare October 8, 2024 01:27
@graphite-app graphite-app bot merged commit 00df6e5 into main Oct 8, 2024
20 of 26 checks passed
@graphite-app graphite-app bot deleted the don/10-07-fix_linter_friendly_diagnostic_messages_for_no-else-return_ branch October 8, 2024 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-linter Area - Linter C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants