Skip to content

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

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

Conversation

ryzokuken
Copy link
Member

Fixes: #536

Took a stab at it, let me know what you think about the phrasing.

@ryzokuken ryzokuken self-assigned this Apr 22, 2025
Copy link
Contributor

@gibson042 gibson042 left a 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.
Copy link
Contributor

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.

Copy link
Member Author

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.
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

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").
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- 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"`).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API naming conventions should be documented
3 participants