-
-
Notifications
You must be signed in to change notification settings - Fork 4k
chore(lint): turn on curly
again
#10931
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
curly
againcurly
again
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10931 +/- ##
==========================================
+ Coverage 42.69% 43.44% +0.74%
==========================================
Files 262 262
Lines 16086 16424 +338
Branches 1545 1630 +85
==========================================
+ Hits 6868 7135 +267
- Misses 9206 9280 +74
+ Partials 12 9 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
return Targets.Guild; | ||
} | ||
|
||
if (target < 20) { |
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'd say these should be else if
now to keep it a little easier to read. Or disable curly rule for this file.
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.
Yeah I spotted this file in the diff too and I am torn, else if
is also messy... I wish there was an easier way to make this mapping 😢
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.
We could list out the numbers and make a map.
Or, this:
const RANGES = [
{ max: 10, type: Targets.Guild },
{ max: 20, type: Targets.Channel },
{ max: 30, type: Targets.User },
{ max: 40, type: Targets.Role },
{ max: 50, type: Targets.Invite },
{ max: 60, type: Targets.Webhook },
{ max: 70, type: Targets.Emoji },
{ max: 80, type: Targets.Message },
{ max: 83, type: Targets.Integration },
{ max: 86, type: Targets.StageInstance },
{ max: 100, type: Targets.Sticker },
{ max: 110, type: Targets.GuildScheduledEvent },
{ max: 120, type: Targets.Thread },
{ max: 130, type: Targets.ApplicationCommand },
{ max: 140, type: Targets.SoundboardSound },
{ max: 143, type: Targets.AutoModeration },
{ max: 146, type: Targets.User }
];
// In the class:
static targetType(target) {
return target >= 163 && target <= 165 ? Targets.GuildOnboardingPrompt : ranges.find(r => target < r.max) ?? Targets.Unknown;
}
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.
Not a fan
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.
If we were to define ranges like that, we'd have start and end, not just max, and we'd not have edgecases in the function that returns the type. That said, this is also not the greatest move
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.
Guess it is back to contemplating disabling the rule for these lines then.
if (this.messageId && interaction.message?.id !== this.messageId) return null; | ||
if (this.channelId && interaction.channelId !== this.channelId) return null; | ||
if (this.guildId && interaction.guildId !== this.guildId) return null; | ||
if (this.interactionType && interaction.type !== this.interactionType) { |
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.
Combine all these in a single if statement?
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.
God no XD
if (this.messageId && interaction.message?.id !== this.messageId) return null; | ||
if (this.channelId && interaction.channelId !== this.channelId) return null; | ||
if (this.guildId && interaction.guildId !== this.guildId) return null; | ||
if (this.type && interaction.type !== this.type) { |
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.
Ditto
const embedUpdate = !message.author && !message.attachments; | ||
if (embedUpdate) return this.id === message.id && this.embeds.length === message.embeds.length; | ||
if (embedUpdate) { |
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.
Move the condition directly into the if() now, as embedUpdate
isn't used elsewhere.
return obj; | ||
} | ||
|
||
if (obj instanceof Date) { |
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.
Can be combined with the previous if
Please describe the changes this PR makes and why it should be merged:
Each commit does a specific change only, so you can review just one of them. This just turns on curly again
Status and versioning classification: