Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): no-unsafe-enum-comparison handles switch cases#7898

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg commentedNov 11, 2023
edited
Loading

PR Checklist

Overview

Recreates#7541. Description pasted following.

Currently, theno-unsafe-enum-comparison rule handles comparisons (e.g.BinaryExpression) but it does not handle switch statements. My PR makes the rule handle both.

This was an oversight in my original design of this rule, and I consider this to be a bug. However, I have marked the PR asfeat instead offix to be more conservative; feel free to change it if you wish.

Code Change Summary

I refactored the logic in theBinaryExpression selector and put it inside of a function calledisMismatchedComparison.
Then, I can call that function from multiple selectors. The changes should be pretty straightforward to understand.

Other Notes

I have reworked the documentation for this rule a bit, as the original text is now no longer accurate, because TypeScript has made number enums more safe in version 5.0. Thus, I rewrote the document to focus on the string case, adding a line to emphasize that the rule is still useful if you choose to use string enums over number enums.

Zamielland others added13 commitsAugust 26, 2023 14:30
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@JoshuaKGoldberg!

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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedNov 11, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commita91d93a
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6552211c8f48a6000872217b
😎 Deploy Previewhttps://deploy-preview-7898--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: 98 (🔴 down 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (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 yourNetlify site configuration.

@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelNov 11, 2023
@bradzacherbradzacher changed the titlefeat: no-unsafe-enum-comparison handles switch casesfeat(eslint-plugin): no-unsafe-enum-comparison handles switch casesNov 13, 2023
@JoshuaKGoldbergJoshuaKGoldberg merged commit72cb9e4 intotypescript-eslint:mainNov 13, 2023
@JoshuaKGoldbergJoshuaKGoldberg deleted the enum-comparison-switch-merge branchNovember 13, 2023 16:02
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsNov 21, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers
No reviews
Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[no-unsafe-enum-comparison] consider evaluatingswitch statements
2 participants
@JoshuaKGoldberg@Zamiell

[8]ページ先頭

©2009-2025 Movatter.jp