Skip to content

Commit

Permalink
Internally mutating the option argument causes unexpected behaviour.
Browse files Browse the repository at this point in the history
Example:

    var options = {regexp: true};
    JSHINT("/*jshint regexp: false */\nvar c = /a.b/;", options);
    JSHINT("var a = /d.e/;", options);

In the second call, `options.regexp == false`, and no errors are logged.
  • Loading branch information
brentlintner committed Mar 27, 2012
1 parent 553dd40 commit bf051de
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions jshint.js
Expand Up @@ -4091,7 +4091,10 @@ loop: for (;;) {
// The actual JSHINT function itself.

var itself = function (s, o, g) {
var a, i, k;
var a, i, k, x,
optionKeys,
newOptionObj = {};

JSHINT.errors = [];
JSHINT.undefs = [];
predefined = Object.create(standard);
Expand All @@ -4110,10 +4113,14 @@ loop: for (;;) {
}
}
}
option = o;
} else {
option = {};
optionKeys = Object.keys(o);
for (x = 0; x < optionKeys.length; x++) {
newOptionObj[optionKeys[x]] = o[optionKeys[x]];
}
}

option = newOptionObj;

option.indent = option.indent || 4;
option.maxerr = option.maxerr || 50;

Expand Down

0 comments on commit bf051de

Please sign in to comment.