-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Editorial: Quote properties across the board. #1302
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
Conversation
I don't understand this part. (slightly off-topic because this is not the approach you went with) |
|
@mathiasbynens Sorry for the unclear wording—what I mean is that because We could do either, but the reason approach 1 would be a larger diff is because (I believe) it implies quoting method names everywhere, even in a phrase like "a generic |
|
Everything changed in this PR is an identifier, in fact. |
@mathiasbynens @domenic Hmm, do you think "bound identifier" would be adequately clear then? It would seem that given these...
...and the fact that But either way, it would be nicer to avoid confusing people, so please let me know. 😄 |
I'm not sure what would be clearer, as I'm not sure what distinction you're trying to capture. I gather you think some things should be quoted, and some shouldn't. But so far the justification given is that identifiers should be unquoted, and that doesn't help, because that means everything in this PR should be unquoted. So I'm not sure what you're trying to accomplish. Separately it seems you are discussing the distinction between identifiers and identifier names, but I'm not sure I see the relevance. |
I mean, as Mathias noted, this discussion is rather tangential to the current state of the PR. Insofar as it's just me seeking knowledge or opinions, it could be taken to IRC instead. I imagine the context of this PR is a bit unclear. Admittedly my original idea was rather the opposite (to never quote property names except when actually passing a string literal), but my goal here is nothing other to find a consistent solution that pleases our editors and some hypothetical future linting tool alike. Thus if we're going to quote property names in general, the key questions are what to do about properties of the global object like |
I'd agree with @domenic that all the changes here seem to be around already valid identifier tokens. I'm not entirely sure if this increases consistency in any way. If it could be explained why these particular tokens are being distinguished and for what reason. Primordials like the |
It does. E.g., in the current spec, there are 74 occurrences of
and 133 occurrences of
In rkirsling's quote-all-properties branch, the respective counts are 185 and 23. (The unquoted remnant is mostly due to properties of the global object, as rkirsling raised above.) It would certainly be possible to resolve the inconsistency in the other direction, it's just that this direction is roughly what came out of the discussion for #1239. |
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.
this change seems to work towards consistency
Turns out a chunk of the "unquoted remnant" that @jmdyck mentioned was missed spots (must've been juggling too many regexes, as I have every recollection of addressing them... 🤔), but indeed, the other ones are of two varieties:
@bterlson also suggested going ahead with converting these |
edeec40
to
0a7a312
Compare
Rebased, rechecked, and resquashed. |
Any chance our current editors could review this? (Just to reiterate, my singular goal here has been to address existing inconsistencies; if we'd like to split this up or reconsider the approach or what have you, that's all fine by me.) |
c5702ec
to
f782f71
Compare
Resolved conflicts again. |
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.
overall this is a great improvement.
it would be really nice if we had some kind of programmatic enforcement of the formatting, to prevent inevitable future drift.
A start would be to check that you don't get any output from:
and
@rkirsling: Running the first of those commands on the current branch finds
in Function.prototype.toString, which maybe snuck in on a rebase. |
c7f5b6f
to
ee97ddc
Compare
(Resolved conflicts.) |
ee97ddc
to
2d40e7d
Compare
Rebased again. |
2d40e7d
to
18e5ffb
Compare
Rebased following #1592. On that note, if jettisoning the last commit here would make the PR as a whole easier to swallow, that would be fine—it is, after all, barely even the tip of a massive iceberg in itself. |
18e5ffb
to
deaf4c3
Compare
Rebased. |
deaf4c3
to
d7d8472
Compare
- Quote properties as `"foo"`. - Add missing backticks. - value `foo` → value *foo*. - Fix a few neighboring typos.
d7d8472
to
1d613b0
Compare
- Quote properties as `"foo"`. - Add missing backticks. - value `foo` → value *foo*. - Fix a few neighboring typos.
1d613b0
to
fc21887
Compare
"NativeError" is a metavariable that stands in for each of the Native Error types, so it should always be italicized. The 2 occurrences in headings were italicized in ES5, but lost their italics in one of the ES6 drafts. For the value of the 'name' property, it was italicized when introduced in f3743b5 (PR tc39#270) but lost its italics in fc21887 (PR tc39#1302).
- Insert missing word "function" - add underscores to "M" in a couple spots - At "anonymous function", insert "built-in". The usual formula for these clauses is: "A Foo function is an anonymous built-in function ..." - Change some "numeric value" to "Number value". They used to be synonyms, but "numeric value" now includes BigInt, which is not meant in these contexts. - Italicize "NativeError" in 3 spots. "NativeError" is a metavariable that stands in for each of the Native Error types, so it should always be italicized. The 2 occurrences in headings were italicized in ES5, but lost their italics in one of the ES6 drafts. For the value of the 'name' property, it was italicized when introduced in f3743b5 (tc39#270) but lost its italics in fc21887 (tc39#1302). - Refer to parameters in PromiseResolve preamble
Follow-up to #1239.
On IRC, two ideas were raised as to a consistent, enforceable approach to quoting properties:
@ljharb suggested always using quotes unless that property can also be considered an identifier (hence "
"prototype"
property" but "Function
property of the global object" ).@jmdyck suggested using quotes just when referring to it as a property (hence "
"Function"
property" but "Function
constructor", ""toString"
property" but "toString
method").Either approach is acceptable to me, but I am starting with the latter, as the diff is more conservative.
I've also included a few related commits which fix neighboring typos, add missing backticks (e.g. to Array.prototype in plaintext), and turn "value
foo
" into "value foo" where trivial. The last of these could be a separate PR if desired; I've included it here since it too was brought up in the last PR.