From 3b19cff1bcdd0041eaecaf97687f445b6c27aeb3 Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Thu, 14 May 2015 11:32:50 -0700 Subject: [PATCH 1/2] Added cuddled-else section and revised whitespace rules --- README.md | 25 ++++++++++++++++++++++--- linters/jshintrc | 15 +++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a4f1d51d69..b76efe1c28 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,25 @@ } ``` + - Use "cuddled else" (aka 1TBS) braces for if-else blocks. + + ```javascript + // bad + if (test) { + return false; + } + else { + return true; + } + + // good + if (test) { + return false; + } else { + return true; + } + ``` + **[⬆ back to top](#table-of-contents)** @@ -735,12 +754,12 @@ ## Whitespace - - Use soft tabs set to 2 spaces + - Use soft tabs set to 4 spaces ```javascript // bad function() { - ∙∙∙∙var name; + ∙∙var name; } // bad @@ -750,7 +769,7 @@ // good function() { - ∙∙var name; + ∙∙∙∙var name; } ``` diff --git a/linters/jshintrc b/linters/jshintrc index cc6e398b40..784a2637ce 100644 --- a/linters/jshintrc +++ b/linters/jshintrc @@ -25,14 +25,14 @@ // Prohibit use of == and != in favor of === and !==. "eqeqeq": true, - // Enforce tab width of 2 spaces. - "indent": 2, + // Enforce tab width of 4 spaces. + "indent": 4, // Prohibit use of a variable before it is defined. "latedef": true, // Enforce line length to 80 characters - "maxlen": 80, + // "maxlen": 80, // Require capitalized names for constructor functions. "newcap": true, @@ -41,7 +41,11 @@ "quotmark": "single", // Enforce placing 'use strict' at the top function scope - "strict": true, + // "strict": true, + + // do not complain for lack of 'use strict'; + "globalstrict": false, + "strict": false, // Prohibit use of explicitly undeclared variables. "undef": true, @@ -49,6 +53,9 @@ // Warn when variables are defined but never used. "unused": true, + // Use JS ES5 + "es5": true + /* * RELAXING OPTIONS * ================= From 8a0ea0a56cfbbbb6ae8e68e712d5be5ff33ab368 Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Thu, 14 May 2015 11:34:15 -0700 Subject: [PATCH 2/2] Added 1TBS link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b76efe1c28..7847e54bf3 100644 --- a/README.md +++ b/README.md @@ -637,7 +637,7 @@ } ``` - - Use "cuddled else" (aka 1TBS) braces for if-else blocks. + - Use "cuddled else" (aka [1TBS](http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS)) braces for if-else blocks. ```javascript // bad