From 60d755e32ed3f2926857c80d206d3fa753e8a381 Mon Sep 17 00:00:00 2001 From: Josh Perez Date: Thu, 6 Aug 2015 20:48:41 -0700 Subject: [PATCH 1/2] No semicolons --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index 0e909159da..512a961389 100644 --- a/README.md +++ b/README.md @@ -2181,4 +2181,46 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. We encourage you to fork this guide and change the rules to fit your team's style guide. Below, you may list some amendments to the style guide. This allows you to periodically update your style guide without having to deal with merge conflicts. + - [20.1](#20.1) **No semicolons. Use the ASI.** + + ```javascript + // good + (function() { + const name = 'Skywalker' + return name + })() + + // meh + (() => { + const name = 'Skywalker'; + return name; + })(); + + // ok too, but never do this, give the function a name instead + ;(() => { + const name = 'Skywalker' + return name + })() + + // no, why would you ever start a line with an array. Give it a name + [1, 2, 3].map(addOne) + + // starting a line with an arithmetic operator is also weird + +1 + + // yes you need semicolons for for stmts, but don't for-loop unless + // there's a valid reason for it + for (let i = 0; i < iterations.length; i += 1) { + } + ``` + + Semicolons are entirely avoidable, in some cases you might need one. Use + judiciously. + + [Read more](https://medium.com/@goatslacker/no-you-dont-need-semicolons-148d936b9cf2). + +**[⬆ back to top](#table-of-contents)** + + + # }; From e2e0e10ff957df1f0a2b25489323d092eba01b3e Mon Sep 17 00:00:00 2001 From: Burkhard Reffeling Date: Mon, 28 Sep 2015 17:14:15 +0100 Subject: [PATCH 2/2] Remove superfluous semicolon Yeah, that... ;) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 512a961389..0667f126dd 100644 --- a/README.md +++ b/README.md @@ -2223,4 +2223,4 @@ We encourage you to fork this guide and change the rules to fit your team's styl -# }; +# }