.jshintrc: Add the "forin" option & fix fallout

Also added few missing |hasOwnProperty| calls that JSHint didn't detect
because it only looks whether there is an |if| statement wrapping the
loop body.
redux
David Majda 11 years ago
parent f22d7aabb5
commit 95fd64ec15

@ -2,6 +2,7 @@
"curly": true, "curly": true,
"eqeqeq": true, "eqeqeq": true,
"evil": true, "evil": true,
"forin": true,
"laxbreak": true, "laxbreak": true,
"noempty": true, "noempty": true,
"nonew": true, "nonew": true,

@ -70,7 +70,9 @@ function addExtraOptions(options, json) {
} }
for (var key in extraOptions) { for (var key in extraOptions) {
options[key] = extraOptions[key]; if (extraOptions.hasOwnProperty(key)) {
options[key] = extraOptions[key];
}
} }
} }

@ -48,7 +48,9 @@ module.exports = {
}); });
for (stage in passes) { for (stage in passes) {
utils.each(passes[stage], runPass); if (passes.hasOwnProperty(stage)) {
utils.each(passes[stage], runPass);
}
} }
switch (options.output) { switch (options.output) {

@ -24,7 +24,9 @@ module.exports = {
var converted = {}, stage; var converted = {}, stage;
for (stage in passes) { for (stage in passes) {
converted[stage] = utils.values(passes[stage]); if (passes.hasOwnProperty(stage)) {
converted[stage] = utils.values(passes[stage]);
}
} }
return converted; return converted;

@ -69,7 +69,9 @@ var utils = {
keys: function(object) { keys: function(object) {
var result = []; var result = [];
for (var key in object) { for (var key in object) {
result.push(key); if (object.hasOwnProperty(key)) {
result.push(key);
}
} }
return result; return result;
}, },
@ -77,7 +79,9 @@ var utils = {
values: function(object) { values: function(object) {
var result = []; var result = [];
for (var key in object) { for (var key in object) {
result.push(object[key]); if (object.hasOwnProperty(key)) {
result.push(object[key]);
}
} }
return result; return result;
}, },
@ -85,15 +89,19 @@ var utils = {
clone: function(object) { clone: function(object) {
var result = {}; var result = {};
for (var key in object) { for (var key in object) {
result[key] = object[key]; if (object.hasOwnProperty(key)) {
result[key] = object[key];
}
} }
return result; return result;
}, },
defaults: function(object, defaults) { defaults: function(object, defaults) {
for (var key in defaults) { for (var key in defaults) {
if (!(key in object)) { if (defaults.hasOwnProperty(key)) {
object[key] = defaults[key]; if (!(key in object)) {
object[key] = defaults[key];
}
} }
} }
}, },

@ -15,7 +15,9 @@ describe("generated parser", function() {
* changed later. * changed later.
*/ */
for (key in options) { for (key in options) {
clonedOptions[key] = options[key]; if (options.hasOwnProperty(key)) {
clonedOptions[key] = options[key];
}
} }
describe( describe(
@ -123,10 +125,12 @@ describe("generated parser", function() {
} else { } else {
if (details) { if (details) {
for (key in details) { for (key in details) {
if (!this.env.equals_(e[key], details[key])) { if (details.hasOwnProperty(key)) {
this.message = buildKeyMessage(key, e[key]); if (!this.env.equals_(e[key], details[key])) {
this.message = buildKeyMessage(key, e[key]);
return false; return false;
}
} }
} }
} }

@ -29,9 +29,11 @@ beforeEach(function() {
if (!isObject(value)) { return false; } if (!isObject(value)) { return false; }
for (key in details) { for (key in details) {
if (!(key in value)) { return false; } if (details.hasOwnProperty(key)) {
if (!(key in value)) { return false; }
if (!matchDetails(value[key], details[key])) { return false; } if (!matchDetails(value[key], details[key])) { return false; }
}
} }
return true; return true;

@ -145,10 +145,12 @@ describe("PEG.js grammar parser", function() {
} else { } else {
if (details) { if (details) {
for (key in details) { for (key in details) {
if (!this.env.equals_(e[key], details[key])) { if (details.hasOwnProperty(key)) {
this.message = buildKeyMessage(key, e[key]); if (!this.env.equals_(e[key], details[key])) {
this.message = buildKeyMessage(key, e[key]);
return false; return false;
}
} }
} }
} }

Loading…
Cancel
Save