Wording in "Why you should use semicolons" can be improved #214
qgustavor
started this conversation in
Discussions
Replies: 1 comment
-
Please open a PR with your suggestions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The wording in "Why you should use semicolons" section is weird. The section, introduced in 7488b34 after issue #112, was based on a Tweet and kept the almost same wording. In the other hand the section title is not consistent with the rest of text: while other titles are simple assertions, such as "true is false" or "function is not a function", or questions such as "Is this multiple inheritance?", the title of this one is an recommendation.
Also, why the "standard JavaScript" wording? It's way too similar to the JavaScript Standard Style which avoids using semicolons. I see that it comes from the Tweet, but it could be better worded to avoid this reference. In fact, if it's a reference to this style guide, then it's a bad example as this guide explicitly says would should use semicolons when starting lines with
[
and lists other cases where it's needed.I like Standard because it makes programmers think about the actual JavaScript issue: automatic semicolon insertion. Teaching "you should use semicolons" for me is just a workaround for that and which may fail if not learned properly. If someone thinks "I will just use semicolons like in other languages" then it will lead to some pitfalls like adding a line break after a
return
: works in PHP, works in C, not in JavaScript.The wording can be improved. I suggest to change the title to something similar to "Semicolons are automatically added, right?" or "Are semicolons optional?" or "Automatically added semicolons", something to fit the style used in other examples. The current example that shows a situation where a semicolon was expected to be added (by someone which don't knows ASI) can be kept, but would be nice if an example where ASI adds a semicolon where it's not expected was added, maybe this one:
Of course a linter would detect the early return, but there isn't a single example in the text that recommends using one.
Issue written after this comment.
Beta Was this translation helpful? Give feedback.
All reactions