Skip to content

Commit

Permalink
Fix for unnecessary semicolon + white
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker authored and valueof committed Jul 27, 2012
1 parent 3a36171 commit f0d5630
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,9 @@ loop: for (;;) {
if (option.white) {
left = left || token;
right = right || nexttoken;
if (left.value === ";" && right.value === ";") {
return;
}
if (left.line === right.line && left.character === right.from) {
left.from += (left.character - left.from);
warning("Missing space after '{a}'.",
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1161,3 +1161,20 @@ exports.browser = function () {
TestRun().test(src, { browser: true, undef: true });

};

exports.unnecessarysemicolon = function () {
var code = [
"function foo() {",
" var a;;",
"}"
];

TestRun()
.addError(2, "Unnecessary semicolon.")
.test(code);

TestRun()
.addError(2, "Unnecessary semicolon.")
.test(code, { white: true });

};

0 comments on commit f0d5630

Please sign in to comment.