8000 chore: enable no-unreachable-loop by abrahamguo · Pull Request #9540 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

chore: enable no-unreachable-loop #9540

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

Merged

Conversation

abrahamguo
Copy link
Contributor
@abrahamguo abrahamguo commented Jul 11, 2024

PR Checklist

Overview

Enable no-unreachable-loop (docs)

@typescript-eslint
8000
Copy link
Contributor

Thanks for the PR, @abrahamguo!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link
netlify bot commented Jul 11, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 8bf8fd3
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/669c1774f3b5d80008c88caa
😎 Deploy Preview https://deploy-preview-9540--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 84 (🔴 down 10 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.45%. Comparing base (5d895b7) to head (8bf8fd3).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9540      +/-   ##
==========================================
- Coverage   88.45%   88.45%   -0.01%     
==========================================
  Files         422      422              
  Lines       14694    14693       -1     
  Branches     4299     4299              
==========================================
- Hits        12997    12996       -1     
  Misses       1372     1372              
  Partials      325      325              
Flag Coverage Δ
unittest 88.45% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/eslint-plugin/src/rules/no-mixed-enums.ts 97.10% <100.00%> (-0.09%) ⬇️
...ckages/eslint-plugin/src/rules/no-unsafe-return.ts 96.77% <100.00%> (+0.05%) ⬆️

@@ -127,6 +127,7 @@ function foo(): Set<number> {
return [] as any[];
}
`,
'const foo: (() => void) | undefined = () => 1;',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionType.getCallSignatures() can return an empty array, but that code path was not being tested. This ensures that the code path is now covered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was brought to light because when I initially refactored the rule to assume that getCallSignatures()[0] was always defined, the tests passed, but the rule crashed when linting this repo, therefore showing that a test was missing.

: AllowedType.Number;
}
}
const [{ initializer }] = (declarations[0] as ts.EnumDeclaration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this because this exposes a bug (not sure if it's intentional)! Checking declarations[0] is almost always a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this truly a bug? Is it possible for a symbol to have multiple declarations, that would be different from each other?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; if a symbol returns multiple declarations, that means these sites are merged together and should be treated as one. That's my understanding; I haven't verified it.

kirkwaiblinger
kirkwaiblinger previously approved these changes Jul 13, 2024
Copy link
Member
@kirkwaiblinger kirkwaiblinger left a commen 8000 t

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate you being proactive about adding that test 🙂

Josh-Cena
Josh-Cena previously approved these changes Jul 19, 2024
kirkwaiblinger
kirkwaiblinger previously approved these changes Jul 20, 2024
@JoshuaKGoldberg JoshuaKGoldberg changed the title chore: enable no-unreachable-loop fix(eslint-plugin): correct no-unsafe-return call signatures by enabling no-unreachable-loop internally Jul 20, 2024
Copy link
Me 8000 mber
@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A chore so good, it got promoted to a fix(eslint-plugin). Nice! 💪

@Josh-Cena
Copy link
Member

@JoshuaKGoldberg I don't think there are behavior differences with this PR? The logic of no-unsafe-return wasn't buggy, I think (well it could be, since only caring about the first signature still seems fishy).

@JoshuaKGoldberg
Copy link
Member

Oh, gotcha - I misinterpreted. Never mind then. 🙂

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): correct no-unsafe-return call signatures by enabling no-unreachable-loop internally chore: enable no-unreachable-loop Jul 20, 2024
@Josh-Cena Josh-Cena dismissed stale reviews from JoshuaKGoldberg, kirkwaiblinger, and themself via 8bf8fd3 July 20, 2024 20:00
@JoshuaKGoldberg JoshuaKGoldberg merged commit 6647f7e into typescript-eslint:main Jul 20, 2024
62 of 63 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0