diff --git a/README.md b/README.md index cd099b56ce..708fd29117 100644 --- a/README.md +++ b/README.md @@ -363,27 +363,28 @@ var superPower = new SuperPower(); ``` - - Use one `var` declaration for multiple variables and declare each variable on a newline. + - Use one `var` declaration per variable and declare each variable on a newline. ```javascript // bad + var items = getItems(), + goSportsTeam = true, + dragonball = 'z'; + + // good var items = getItems(); var goSportsTeam = true; var dragonball = 'z'; - // good - var items = getItems(), - goSportsTeam = true, - dragonball = 'z'; ``` - Declare unassigned variables last. This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables. ```javascript // bad - var i, len, dragonball, - items = getItems(), - goSportsTeam = true; + var i, len, dragonball; + var items = getItems(); + var goSportsTeam = true; // bad var i, items = getItems(), @@ -392,11 +393,11 @@ len; // good - var items = getItems(), - goSportsTeam = true, - dragonball, - length, - i; + var items = getItems(); + var goSportsTeam = true; + var dragonball; + var length; + var i; ``` - Assign variables at the top of their scope. This helps avoid issues with variable declaration and assignment hoisting related issues. diff --git a/linters/jshintrc b/linters/jshintrc index cc6e398b40..2c2836039a 100644 --- a/linters/jshintrc +++ b/linters/jshintrc @@ -40,8 +40,8 @@ // Enforce use of single quotation marks for strings. "quotmark": "single", - // Enforce placing 'use strict' at the top function scope - "strict": true, + // Enforce placing 'use strict' at top of every file. + "globalstrict": true, // Prohibit use of explicitly undeclared variables. "undef": true, @@ -55,5 +55,8 @@ */ // Suppress warnings about == null comparisons. - "eqnull": true + "eqnull": true, + + // Dissallow use of ++ operator + "plusplus": true }