Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

vladfrangu
Copy link
Member

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:

  • This PR only includes non-code changes, like changes to documentation, README, etc.

Copy link

vercel bot commented Jun 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2025 9:42pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2025 9:42pm

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

Attention: Patch coverage is 78.34646% with 110 lines in your changes missing coverage. Please review.

Project coverage is 43.44%. Comparing base (2852a52) to head (12ecc62).

Files with missing lines Patch % Lines
packages/voice/src/networking/Networking.ts 0.00% 27 Missing ⚠️
packages/core/src/client.ts 0.00% 18 Missing ⚠️
packages/voice/src/VoiceConnection.ts 63.63% 16 Missing ⚠️
packages/voice/src/audio/AudioPlayer.ts 50.00% 9 Missing ⚠️
packages/rest/src/lib/handlers/Shared.ts 0.00% 8 Missing ⚠️
packages/rest/src/lib/utils/utils.ts 70.83% 7 Missing ⚠️
packages/voice/src/networking/VoiceWebSocket.ts 0.00% 6 Missing ⚠️
...ackages/voice/src/util/generateDependencyReport.ts 0.00% 6 Missing ⚠️
packages/voice/src/receive/VoiceReceiver.ts 77.77% 4 Missing ⚠️
packages/rest/src/lib/REST.ts 0.00% 3 Missing ⚠️
... and 2 more
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     
Flag Coverage Δ
brokers 31.41% <ø> (ø)
builders 80.53% <100.00%> (+0.01%) ⬆️
collection 100.00% <100.00%> (ø)
core 0.88% <0.00%> (-0.01%) ⬇️
formatters 99.67% <100.00%> (+0.04%) ⬆️
proxy 65.88% <ø> (ø)
rest 86.98% <56.09%> (-0.69%) ⬇️
util 43.28% <ø> (ø)
utilities 100.00% <ø> (ø)
voice 69.63% <53.16%> (-0.82%) ⬇️
ws 36.29% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

return Targets.Guild;
}

if (target < 20) {
Copy link
Member

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.

Copy link
Member Author

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 😢

Copy link
Member

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;
}

Copy link
Member

Choose a reason for hiding this comment

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

Not a fan

Copy link
Member Author

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

Copy link
Member

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) {
Copy link
Member

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?

Copy link
Member Author

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) {
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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

@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

4 participants