Skip to content

Meta: Add naming conventions section in style guide#996

Open
ryzokuken wants to merge 3 commits into
tc39:mainfrom
ryzokuken:fix-536
Open

Meta: Add naming conventions section in style guide#996
ryzokuken wants to merge 3 commits into
tc39:mainfrom
ryzokuken:fix-536

Conversation

@ryzokuken

Copy link
Copy Markdown
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

@gibson042 gibson042 left a comment

Copy link
Copy Markdown
Member

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.

Comment thread docs/style-guide.md Outdated
Comment thread docs/style-guide.md Outdated
Comment thread docs/style-guide.md Outdated
Comment thread docs/style-guide.md Outdated
Comment thread docs/style-guide.md
#### Rationale

- Descriptive names improve code readability and maintainability.
- They reduce the cognitive load for developers, especially those new to the specification.

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

Comment thread docs/style-guide.md Outdated
Comment thread docs/style-guide.md

#### Rationale

- camelCase is a widely accepted convention in JavaScript and aligns with existing ECMA-402 practices.

Copy link
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Comment thread docs/style-guide.md
#### 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
Copy Markdown
Member

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