-
Notifications
You must be signed in to change notification settings - Fork 108
Meta: Add naming conventions section in style guide #996
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
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.
LGTM, but I'd also like @sffc to weigh in.
#### Rationale | ||
|
||
- Descriptive names improve code readability and maintainability. | ||
- They reduce the cognitive load for developers, especially those new to the specification. |
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.
Also, spelled-out names are more accessible to non-native English speakers, because they are more googlable, etc. We are building an i18n library, after all.
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.
What about the immediately following point? I believe it comes close so at the very least I should add something along these lines to it (or after it).
|
||
#### Rationale | ||
|
||
- camelCase is a widely accepted convention in JavaScript and aligns with existing ECMA-402 practices. |
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.
Please dig up the thread in NumberFormat V3 where this was discussed, but we had a number of other reasons. One was that sometimes these strings end up as identifiers, and identifiers in JavaScript are camel case.
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.
Is this it? tc39/proposal-intl-numberformat-v3#9
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 thought that was the original issue but I guess it is tc39/proposal-intl-displaynames#32
Actually, the style guide already says to use camel case here. There is a big section explaining the rationale. I think just refer to that previous section.
#### Guidelines | ||
|
||
- Use camelCase for property names and values that are compound words (good examples: `signDisplay`, `"exceptZero"`). | ||
- Avoid separating words with underscores, hyphens, or other delimiters (historical exceptions: "2-digit", "best fit"). |
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.
- Avoid separating words with underscores, hyphens, or other delimiters (historical exceptions: "2-digit", "best fit"). | |
- Avoid separating words with underscores, hyphens, or other delimiters (historical exceptions: `"2-digit"`, `"best fit"`). |
Fixes: #536
Took a stab at it, let me know what you think about the phrasing.