-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
refactor: switch xURL
to xUrl
#7388
Conversation
What about |
I'll bring this internally and discuss the scope expansion with the rest of the team, I mostly wanted to do those changes incrementally to avoid creating many merge conflicts. |
Not gonna touch on the other arguments since they all seem valid to me and I have nothing against them. This isn't something I disagree with necessarily either, just wanna point out that the first argument isn't really valid:
|
None of the points listed are actually valid though:
|
Apparently lodash's snakeCase function comes with a correctly implemented function, so this is not needed. |
Please describe the changes this PR makes and why it should be merged:
Bringing back the discussion from #6036! But why?!? This change has been made under a number of factors:
A
snakeCase
function convertsiconURL
asicon_u_r_l
, so if we want to support such utility seamlessly, we would need to passiconUrl
. In this case, a name casing mismatch happens as the property isiconURL
inside the builder methods whileicon_url
in the constructor. For consistency, we can use and adopticonUrl
, this way it's the same casing for both the utility function and the chainable methods.This means that this code is now possible:
Or alternatively:
There are several things in the JavaScript ecosystem which uses
Url
, mostly from Firefox but also supported in other places:So
xUrl
isn't that unknown in JavaScript, despiteURL
andURLSearchParams
existing.We are switching to TypeScript soon, which is a language created by the creators of C#, and as such, they share a lot of the naming conventions (see types, interfaces, enums, and namespaces) on top of what they already shared (PascalCase for classes, camelCase for local variables). However, something JavaScript falls short on is having a proper and solid set of rules that define whether or not names should be capitalized or not. Fortunately, C# does, so we can take advantage of this to provide a consistent name casing, as seen below:
Easier to read, now this is subjective, but let me bring some examples:
CreateGuildScheduledEventInviteURLOptions
->CreateGuildScheduledEventInviteUrlOptions
ImageURLOptions
->ImageUrlOptions
StaticImageURLOptions
->StaticImageUrlOptions
bannerURL()
->bannerUrl()
splashURL()
->splashUrl()
iconURL()
->iconUrl()
As a standalone word, we can still use
URL
(aka uppercase), but if it's joined with other words, I'd argue we should go for .NET's rules and replacing PascalCase to camelCase where applicable. After all, they are pretty solid and promote consistency in a way that's widely recognized by many developers and is free of doubts.After all, we used .NET's rules alongside JS's adoption of
Id
to approve the aforementioned PR.I'll also updateDone! discordjs/discord-api-types#313discord-api-types
to reflect the naming change from this PR in a bit!Status and versioning classification: