Skip to content
This repository
Browse code

Make 'indent' behaviour consistent.

When 'indent' is used as a comment it implies 'white' option. (see
L1973). This behaviour came to us as JSLint's legacy and is outside
of scope of this commit. This commit simply makes it so the 'indent'
option passed as an argument to JSHINT also implies 'white'.

Fixes GH-655.
  • Loading branch information...
commit 80277ef7cf1f35137ee653a25ce5664e2752b0db 1 parent 6c80b1c
Anton Kovalyov authored September 25, 2012
4  jshint.js
@@ -4495,12 +4495,16 @@ loop:   for (;;) {
4495 4495
                     }
4496 4496
                 });
4497 4497
             }
  4498
+
4498 4499
             optionKeys = Object.keys(o);
4499 4500
             for (x = 0; x < optionKeys.length; x++) {
4500 4501
                 newOptionObj[optionKeys[x]] = o[optionKeys[x]];
4501 4502
 
4502 4503
                 if (optionKeys[x] === "newcap" && o[optionKeys[x]] === false)
4503 4504
                     newOptionObj["(explicitNewcap)"] = true;
  4505
+
  4506
+                if (optionKeys[x] === "indent")
  4507
+                    newOptionObj.white = true;
4504 4508
             }
4505 4509
         }
4506 4510
 
3  tests/unit/options.js
@@ -1006,13 +1006,14 @@ exports.indentation = function () {
1006 1006
         .addError(6, "Mixed spaces and tabs.")
1007 1007
         .test(src, { indent: 4, white: true });
1008 1008
 
  1009
+    // 'indent' implies 'white'
1009 1010
     TestRun()
1010 1011
         .addError(5, "Mixed spaces and tabs.")
1011 1012
         .addError(5, "Expected 'var' to have an indentation at 5 instead at 7.")
1012 1013
         .addError(6, "Mixed spaces and tabs.")
1013 1014
         .addError(6, "Expected 'var' to have an indentation at 5 instead at 7.")
1014 1015
         .addError(7, "Expected '}' to have an indentation at 3 instead at 5.")
1015  
-        .test(src, { indent: 2, white: true });
  1016
+        .test(src, { indent: 2 });
1016 1017
 };
1017 1018
 
1018 1019
 /*

0 notes on commit 80277ef

Please sign in to comment.
Something went wrong with that request. Please try again.