.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,
"eqeqeq": true,
"evil": true,
"forin": true,
"laxbreak": true,
"noempty": true,
"nonew": true,

@ -70,7 +70,9 @@ function addExtraOptions(options, json) {
}
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) {
utils.each(passes[stage], runPass);
if (passes.hasOwnProperty(stage)) {
utils.each(passes[stage], runPass);
}
}
switch (options.output) {

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

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

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

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

Loading…
Cancel
Save