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] add switch suggestion#7691

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

StyleShit
Copy link
Contributor

@StyleShitStyleShit commentedSep 24, 2023
edited
Loading

Closes#7643

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@StyleShit!

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.

@netlify
Copy link

netlifybot commentedSep 24, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit52af550
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/653168ebad3b8700084a1c0d
😎 Deploy Previewhttps://deploy-preview-7691--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: 99 (🟢 up 4 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.

@StyleShitStyleShitforce-pushed thetweak/no-unsafe-enum-comparison-suggestion branch from8725058 to0471e12CompareSeptember 24, 2023 12:07
@StyleShitStyleShit changed the titletweak(eslint-plugin): [no-unsafe-enum-comparison] add switch suggestionfeat(eslint-plugin): [no-unsafe-enum-comparison] add switch suggestionSep 24, 2023
@nx-cloud
Copy link

nx-cloudbot commentedSep 24, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit52af550. 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 19 targets

Sent with 💌 fromNxCloud.

@StyleShit
Copy link
ContributorAuthor

@JoshuaKGoldberg

OK, should be better now, but I still can't figure out the types there 😓

JoshuaKGoldberg reacted with eyes emoji

@StyleShitStyleShit marked this pull request as ready for reviewOctober 3, 2023 12:27
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Really good start so far! The code looks clean and I like the general direction. 😄

Left a few comments and suggestions for how to overcome the// @ts-expect-errors. I suspect they'll end up showing you a bunch more test cases to add. Have fun!

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelOct 10, 2023
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelOct 17, 2023
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit.Apple, Vegetable.Lettuce]
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit.Apple, Vegetable.Lettuce]
* - T extends Fruit --> [Fruit]
*/

Choose a reason for hiding this comment

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

[Praise] Great comments, thanks for continuing the existing standard 🙂

StyleShit reacted with rocket emoji
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment
edited
Loading

Choose a reason for hiding this comment

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

Looking great! Structure is solid, good test coverage, super readable code. Nice!

Just requesting changes on a bit more test coverage and somegetText() ->name touchups.

Timmy from the Shaun the Sheep movie giving two thumbs up

'a' = 1,
}
declare const stringKey: StringKey;
stringKey === StringKey['a'];

Choose a reason for hiding this comment

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

StringKey['a'];

Just confirming explicitly in case someone looks at this in the future: I think it's fine to have it look likeStringKey['a'] instead ofStringKey.a. They're functionally the same, and there are other rules around stylistic concerns.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelOct 17, 2023
return `${enumName}['${memberNameIdentifier.text}']`;

case ts.SyntaxKind.ComputedPropertyName:
return `${enumName}[${memberNameIdentifier.expression.getText()}]`;
Copy link
ContributorAuthor

@StyleShitStyleShitOct 17, 2023
edited
Loading

Choose a reason for hiding this comment

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

had to use.getText() here, there is no.text for some reason
seems like it's fine? See the tests for that as a reference

Choose a reason for hiding this comment

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

The type ofmemberNameIdentifier.expression ists.Expression, which is a pretty wide type. You couldas assert it to the union of types that are actually allowed as enum member names... or just go with.getText(). If the unit tests aren't showing any bad behavior, it's probably fine. 😎

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I would probably keep it like this, seems fine in the tests (unless I'm missing some cases?)

Choose a reason for hiding this comment

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

The existing bugs in#7768 make me nottoo motivated to get every single possible edge case in this PR. The tests you've added are pretty great. Thanks!

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelOct 17, 2023
Comment on lines +844 to +847
enum ComputedKey {
[\`test-
key\` /* with comment */] = 1,
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

(Why is this even legal?!)

Choose a reason for hiding this comment

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

to make our lives harder 🫠

Copy link
ContributorAuthor

@StyleShitStyleShitOct 19, 2023
edited
Loading

Choose a reason for hiding this comment

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

It's hard enough without it! 😭

JoshuaKGoldberg reacted with laugh emoji
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Nice! Great investigation resulting in a nice set of test coverage & fixing. Thanks for working with me on this on@StyleShit!

We can always tackle more edge cases in the followup#7768.

Crayon cartoon drawing of a purple cat/bear thing happily gesture-hugging and saying 'THANKYOU'

StyleShit reacted with heart emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelOct 19, 2023
@JoshuaKGoldbergJoshuaKGoldberg merged commit53d5263 intotypescript-eslint:mainOct 19, 2023
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsOct 27, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

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.

Enhancement: [no-unsafe-enum-comparison] Suggestion fixer to switch to enum value
2 participants
@StyleShit@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp