Skip to content

Commit

Permalink
Don't warn when Error() is used without 'new'.
Browse files Browse the repository at this point in the history
Closes jshint#1590.
  • Loading branch information
Anton Kovalyov committed Mar 26, 2014
1 parent 7320df1 commit 2fecdea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ var JSHINT = (function () {
}


// Functions for conformance of style.
// Functions for conformance of style.

function nobreaknonadjacent(left, right) {
left = left || state.tokens.curr;
Expand Down Expand Up @@ -2442,7 +2442,7 @@ var JSHINT = (function () {
if (left) {
if (left.type === "(identifier)") {
if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
if ("Number String Boolean Date Object".indexOf(left.value) === -1) {
if ("Number String Boolean Date Object Error".indexOf(left.value) === -1) {
if (left.value === "Math") {
warning("W063", left);
} else if (state.option.newcap) {
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/fixtures/newcap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ var bat = new myAnimal();

rat = iAnimal();
bat = myAnimal();

// Make sure we don't warn on Error, Number, etc.
Error();
Number();
String();
Boolean();

0 comments on commit 2fecdea

Please sign in to comment.