-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
docs: [no-unsafe-enum-comparison] clarify motivation and applicability #10029
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
docs: [no-unsafe-enum-comparison] clarify motivation and applicability #10029
Conversation
Thanks for the PR, @kirkwaiblinger! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 03d76de. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the examples! But there's a lot of text here, maybe we can trim down in this specific page?
break; | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These examples are really good at explaining what's going on... but they're pretty tall vertically. You have to scroll down pretty far to see the second one.
Proposal: how about...
- Moving simplified versions of those examples into the Examples settings
- Filing a followup issue to write a longer blog post on all the dangers of enums that can be caught by this & other lint rules?
I think we have enough enum rules to justify a full blog post:
- This one
- @typescript-eslint/no-duplicate-enum-values
- @typescript-eslint/no-mixed-enums
- @typescript-eslint/no-unsafe-enum-comparison
- @typescript-eslint/prefer-enum-initializers
- @typescript-eslint/prefer-literal-enum-member
- Even better, Rule proposal: Disallow literals where enums are expected #308 would be great to have too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is good feedback. Made changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filed #10075
packages/eslint-plugin/docs/rules/no-unsafe-enum-comparison.mdx
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10029 +/- ##
=======================================
Coverage 85.99% 85.99%
=======================================
Files 428 428
Lines 14912 14912
Branches 4332 4332
=======================================
Hits 12823 12823
Misses 1744 1744
Partials 345 345
Flags with carried forward coverage won't be shown. Click here to find out more. |
packages/eslint-plugin/docs/rules/no-unsafe-enum-comparison.mdx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✍️
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
PR Checklist
Overview
Updates doc page according to discussion in #8557. In short - clarifies that the rule is about preventing logical errors arising from comparisons between enums and non-enums, not just enums and literals (which is no longer unsafe, just a vector for logical errors).
Co-authored-by: @JoshuaKGoldberg