Permalink
Browse files

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...
1 parent 6c80b1c commit 80277ef7cf1f35137ee653a25ce5664e2752b0db @valueof valueof committed Sep 25, 2012
Showing with 6 additions and 1 deletion.
  1. +4 −0 jshint.js
  2. +2 −1 tests/unit/options.js
View
@@ -4495,12 +4495,16 @@ loop: for (;;) {
}
});
}
+
optionKeys = Object.keys(o);
for (x = 0; x < optionKeys.length; x++) {
newOptionObj[optionKeys[x]] = o[optionKeys[x]];
if (optionKeys[x] === "newcap" && o[optionKeys[x]] === false)
newOptionObj["(explicitNewcap)"] = true;
+
+ if (optionKeys[x] === "indent")
+ newOptionObj.white = true;
}
}
View
@@ -1006,13 +1006,14 @@ exports.indentation = function () {
.addError(6, "Mixed spaces and tabs.")
.test(src, { indent: 4, white: true });
+ // 'indent' implies 'white'
TestRun()
.addError(5, "Mixed spaces and tabs.")
.addError(5, "Expected 'var' to have an indentation at 5 instead at 7.")
.addError(6, "Mixed spaces and tabs.")
.addError(6, "Expected 'var' to have an indentation at 5 instead at 7.")
.addError(7, "Expected '}' to have an indentation at 3 instead at 5.")
- .test(src, { indent: 2, white: true });
+ .test(src, { indent: 2 });
};
/*

0 comments on commit 80277ef

Please sign in to comment.