Skip to content
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

Meta: Update style guide to discuss preferred orderings of elements #831

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

Conversation

ben-allen
Copy link
Collaborator

@ben-allen ben-allen commented Aug 31, 2023

@sffc sffc changed the title Update style guide to discuss preferred orderings of elements Meta: Update style guide to discuss preferred orderings of elements Sep 18, 2023
docs/style-guide.md Outdated Show resolved Hide resolved
Comment on lines 215 to 226
### `resolvedOptions`

:star2: The `resolvedOptions` of Intl objects should appear in the following order:

1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally. :star2:
Copy link
Contributor

Choose a reason for hiding this comment

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

@gibson042 for feedback on this ordering

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems insufficiently stable to me, because we are currently contemplating adding support for -u- extension keys that can currently only be set by options, and could definitely promote a conditional property to mandatory in the future.

Suggested change
### `resolvedOptions`
:star2: The `resolvedOptions` of Intl objects should appear in the following order:
1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally. :star2:
### `resolvedOptions`
:star2: *Properties in the output from `resolvedOptions()` of an Intl object should start with `locale` and otherwise use lexicographic order. Deviations (such as those motivated by semantic order involving a subset of properties) must be documented.* :star2:
Spec changes that add properties should do so in accordance with this recommendation, rather than automatically placing them at the end—relative enumeration order of properties should remain stable over time, but there is no such expectation regarding adjacency.
#### Examples
`Object.keys(new Intl.Segmenter().resolvedOptions())` returns `[ 'locale', 'granularity' ]`. If support for the [Unicode BCP 47 U Extension "dx" key](https://unicode.org/reports/tr35/#UnicodeDictionaryBreakExclusionIdentifier) were added and exposed as `dictionaryBreakExcludedScripts`, that property would belong before `granularity`.

docs/style-guide.md Outdated Show resolved Hide resolved
docs/style-guide.md Outdated Show resolved Hide resolved

## Element Ordering

This section concerns the order in which containers store elements.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the definition of "container" in this context?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This section concerns the order in which containers store elements.
This section concerns the order in which properties are stored and accessed within plain objects.

Does this apply outside of plain objects?

docs/style-guide.md Outdated Show resolved Hide resolved
Comment on lines 215 to 226
### `resolvedOptions`

:star2: The `resolvedOptions` of Intl objects should appear in the following order:

1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally. :star2:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems insufficiently stable to me, because we are currently contemplating adding support for -u- extension keys that can currently only be set by options, and could definitely promote a conditional property to mandatory in the future.

Suggested change
### `resolvedOptions`
:star2: The `resolvedOptions` of Intl objects should appear in the following order:
1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally. :star2:
### `resolvedOptions`
:star2: *Properties in the output from `resolvedOptions()` of an Intl object should start with `locale` and otherwise use lexicographic order. Deviations (such as those motivated by semantic order involving a subset of properties) must be documented.* :star2:
Spec changes that add properties should do so in accordance with this recommendation, rather than automatically placing them at the end—relative enumeration order of properties should remain stable over time, but there is no such expectation regarding adjacency.
#### Examples
`Object.keys(new Intl.Segmenter().resolvedOptions())` returns `[ 'locale', 'granularity' ]`. If support for the [Unicode BCP 47 U Extension "dx" key](https://unicode.org/reports/tr35/#UnicodeDictionaryBreakExclusionIdentifier) were added and exposed as `dictionaryBreakExcludedScripts`, that property would belong before `granularity`.

Comment on lines 11 to 29
- [Examples](#examples)
- [Alternative: Kebab case for all string enumerations](#alternative-kebab-case-for-all-string-enumerations)
- [Pros](#pros)
- [Cons](#cons)
- [Decision](#decision)
- [Alternative: Kebab case for new identifiers only](#alternative-kebab-case-for-new-identifiers-only)
- [Pros](#pros-1)
- [Cons](#cons-1)
- [Decision](#decision-1)
- [Alternative: Use kebab case but also accept camel case](#alternative-use-kebab-case-but-also-accept-camel-case)
- [Pros](#pros-2)
- [Cons](#cons-2)
- [Decision](#decision-2)
- [Identifiers defined outside ECMA-402](#identifiers-defined-outside-ecma-402)
- [Examples](#examples-1)
- [Alternative: Convert identifiers to camel case](#alternative-convert-identifiers-to-camel-case)
- [Pros](#pros-3)
- [Cons](#cons-3)
- [Decision](#decision-3)
Copy link
Member

Choose a reason for hiding this comment

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

Are the whitespace changes necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed it back to the previous spacing

Copy link
Member

Choose a reason for hiding this comment

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

The previous spacing was 4 spaces and your new version has 2 spaces 🙈

@ben-allen ben-allen force-pushed the update-readme-note-on-ordering branch from 5a261af to 1ef3e6a Compare October 12, 2023 16:58
Copy link
Member

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

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

Some old comments and some new ones, let's clean this one up!


## Element Ordering

This section concerns the order in which containers store elements.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This section concerns the order in which containers store elements.
This section concerns the order in which properties are stored and accessed within plain objects.

Does this apply outside of plain objects?

docs/style-guide.md Outdated Show resolved Hide resolved
docs/style-guide.md Outdated Show resolved Hide resolved
Comment on lines 11 to 29
- [Examples](#examples)
- [Alternative: Kebab case for all string enumerations](#alternative-kebab-case-for-all-string-enumerations)
- [Pros](#pros)
- [Cons](#cons)
- [Decision](#decision)
- [Alternative: Kebab case for new identifiers only](#alternative-kebab-case-for-new-identifiers-only)
- [Pros](#pros-1)
- [Cons](#cons-1)
- [Decision](#decision-1)
- [Alternative: Use kebab case but also accept camel case](#alternative-use-kebab-case-but-also-accept-camel-case)
- [Pros](#pros-2)
- [Cons](#cons-2)
- [Decision](#decision-2)
- [Identifiers defined outside ECMA-402](#identifiers-defined-outside-ecma-402)
- [Examples](#examples-1)
- [Alternative: Convert identifiers to camel case](#alternative-convert-identifiers-to-camel-case)
- [Pros](#pros-3)
- [Cons](#cons-3)
- [Decision](#decision-3)
Copy link
Member

Choose a reason for hiding this comment

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

The previous spacing was 4 spaces and your new version has 2 spaces 🙈

@ryzokuken ryzokuken added the meta label Feb 22, 2024
@@ -199,3 +201,22 @@ We could enforce a camel case convention on these strings, such as the following
##### Decision

- Defer the decision on the syntax for identifiers to the other specification when possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ben-allen Please make sure this fully fixes #578

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually we should follow this up with a normative PR for PluralRules.

@ben-allen ben-allen force-pushed the update-readme-note-on-ordering branch 2 times, most recently from f37490f to bafaa25 Compare May 4, 2024 17:30
@ben-allen ben-allen force-pushed the update-readme-note-on-ordering branch from bafaa25 to 1a826c9 Compare May 4, 2024 17:31
@ben-allen ben-allen requested a review from gibson042 May 6, 2024 17:25
Copy link
Member

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

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

Overall LGTM, thanks!

Comment on lines 220 to 225
:star2: <em>The `resolvedOptions` of Intl objects should appear in the following order:

1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally.</em> :star2:
Copy link
Member

Choose a reason for hiding this comment

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

Is this whole section purposefully italicized?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, to match the italicization in the other starred blocks. I do admit that italicizing the list might be a situation where the result of insisting on consistency is ugly enough that it's the wrong thing to do.

Copy link
Member

Choose a reason for hiding this comment

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

I think one way to do it would be to rephrase the first sentence into a summarized guideline, star+italicize it and follow that with the full list. An entire list being starred/italicized doesn't really say much and looks weird.

@ben-allen
Copy link
Collaborator Author

@gibson042 what do you think about this version?

@ben-allen ben-allen force-pushed the update-readme-note-on-ordering branch from 2404d76 to 83a6734 Compare May 7, 2024 18:53
Comment on lines +31 to +33
- [Element Ordering](#element-ordering)
- [General Guidelines](#general-guidelines)
- [resolvedOptions](#resolvedoptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

The extra indentation here breaks Markdown list output: https://github.com/tc39/ecma402/blob/97ba211cddb8a4a22f67e327af05372b545f2bcd/docs/style-guide.md#table-of-contents:~:text=Element%20Ordering

Suggested change
- [Element Ordering](#element-ordering)
- [General Guidelines](#general-guidelines)
- [resolvedOptions](#resolvedoptions)
- [Element Ordering](#element-ordering)
- [General Guidelines](#general-guidelines)
- [resolvedOptions](#resolvedoptions)

docs/style-guide.md Outdated Show resolved Hide resolved
docs/style-guide.md Outdated Show resolved Hide resolved
Comment on lines +218 to +226
### `resolvedOptions`

:star2: *The `resolvedOptions` of `Intl` objects should appear with `locale` first, followed by properties guaranteed to exist that can be set via extension keys, followed by properties guaranteed to exist that are not set by extension keys, and then finally all properties that exist conditionally. Elements in each of these categories should appear in lexicographical order.* :star2:

Order of `resolvedOptions`:
1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reiterating #831 (comment) :

Suggested change
### `resolvedOptions`
:star2: *The `resolvedOptions` of `Intl` objects should appear with `locale` first, followed by properties guaranteed to exist that can be set via extension keys, followed by properties guaranteed to exist that are not set by extension keys, and then finally all properties that exist conditionally. Elements in each of these categories should appear in lexicographical order.* :star2:
Order of `resolvedOptions`:
1. `locale`
2. All properties (given in lexicographical order) that can be set by extension keys and that are guaranteed to exist
3. Properties (in lexicographical order) that are not set by extension keys and that are guaranteed to exist
4. All properties (in lexicographical order) that exist conditionally.
### `resolvedOptions`
:star2: *Properties in the output from `resolvedOptions()` of an Intl object should start with `locale` and otherwise use lexicographic order. Deviations (such as those motivated by semantic order involving a subset of properties) must be documented.* :star2:
Spec changes that add properties should do so in accordance with this recommendation, rather than automatically placing them at the end—relative enumeration order of properties should remain stable over time, but there is no such expectation regarding adjacency.
#### Examples
`Object.keys(new Intl.Segmenter().resolvedOptions())` returns `[ 'locale', 'granularity' ]`. If support for the [Unicode BCP 47 U Extension "dx" key](https://unicode.org/reports/tr35/#UnicodeDictionaryBreakExclusionIdentifier) were added and exposed as `dictionaryBreakExcludedScripts`, that property would belong before `granularity`.

ben-allen and others added 2 commits May 21, 2024 12:05
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants