Skip to content

Commit

Permalink
Fix do not use {a} as constructor, and adds test
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Aug 7, 2012
1 parent 1764ddb commit b197dca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jshint.js
Expand Up @@ -3107,7 +3107,7 @@ loop: for (;;) {
case "Boolean":
case "Math":
case "JSON":
warning("Do not use {a} as a constructor.", token, c.value);
warning("Do not use {a} as a constructor.", prevtoken, c.value);
break;
case "Function":
if (!option.evil) {
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/core.js
Expand Up @@ -429,3 +429,13 @@ exports.testInvalidSource = function () {
.addError(0, "Input is an empty array.")
.test([]);
};

exports.testConstructor = function () {
var code = "new Number(5);";

TestRun()
.addError(1, "Do not use Number as a constructor.", {
character: 1
})
.test(code);
};

0 comments on commit b197dca

Please sign in to comment.