enable JSHint's "forin" test

This commit is contained in:
Jeff Williams 2012-07-04 15:59:33 -07:00
parent 324af73dcf
commit 769a71298e
5 changed files with 62 additions and 48 deletions

View File

@ -2,7 +2,7 @@
"bitwise": true,
"curly": true,
"eqeqeq": false,
"forin": false,
"forin": true,
"immed": false,
"latedef": false,
"newcap": false,

View File

@ -8,6 +8,8 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
var hasOwnProp = Object.prototype.hasOwnProperty;
/** Data representing the environment in which this app is running.
@namespace
*/
@ -151,7 +153,9 @@ function installPlugins(plugins, p) {
//...register event handlers
if (plugin.handlers) {
for (var eventName in plugin.handlers) {
parser.on(eventName, plugin.handlers[eventName]);
if ( hasOwnProp.call(plugin.handlers, eventName) ) {
parser.on(eventName, plugin.handlers[eventName]);
}
}
}
@ -168,8 +172,7 @@ function installPlugins(plugins, p) {
}
function indexAll(docs) {
var lookupTable = {},
hasOwnProp = Object.prototype.hasOwnProperty;
var lookupTable = {};
docs.forEach(function(doc) {
if ( !hasOwnProp.call(lookupTable, doc.longname) ) {

View File

@ -23,14 +23,16 @@ var doop = require("jsdoc/util/doop").doop;
function mapDependencies(index) {
var doclets, doc, len, dependencies = {};
for (var name in index) {
doclets = index[name];
for (var i=0, ii=doclets.length; i<ii; ++i) {
doc = doclets[i];
if (doc.kind === "class") {
dependencies[name] = {};
len = doc.augments && doc.augments.length || 0;
for (var j=0; j<len; ++j) {
dependencies[name][doc.augments[j]] = true;
if ( hasOwnProp.call(index, name) ) {
doclets = index[name];
for (var i=0, ii=doclets.length; i<ii; ++i) {
doc = doclets[i];
if (doc.kind === "class") {
dependencies[name] = {};
len = doc.augments && doc.augments.length || 0;
for (var j=0; j<len; ++j) {
dependencies[name][doc.augments[j]] = true;
}
}
}
}
@ -83,7 +85,9 @@ var doop = require("jsdoc/util/doop").doop;
Sorter.prototype = {
sort: function() {
for (var key in this.dependencies) {
this.visit(key);
if ( hasOwnProp.call(this.dependencies, key) ) {
this.visit(key);
}
}
return this.sorted;
},
@ -94,7 +98,9 @@ var doop = require("jsdoc/util/doop").doop;
throw new Error("Missing dependency: " + key);
}
for (var path in this.dependencies[key]) {
this.visit(path);
if ( hasOwnProp.call(this.dependencies[key], path) ) {
this.visit(path);
}
}
this.sorted.push(key);
}

View File

@ -10,6 +10,7 @@
var tutorial = require('jsdoc/tutorial'),
fs = require('fs'),
hasOwnProp = Object.prototype.hasOwnProperty,
conf = {},
tutorials = {},
finder = /^(.*)\.(x(?:ht)?ml|html?|md|markdown|js(?:on)?)$/i;
@ -97,32 +98,34 @@ exports.resolve = function() {
var item,
current;
for (var name in conf) {
// should we be restrictive here?
// what is someone just wants to keep sample sources in same directory with tutorials?
// I've decided to leave such cases alone
if (!(name in tutorials)) {
continue;
}
if ( hasOwnProp.call(conf, name) ) {
// should we be restrictive here?
// what is someone just wants to keep sample sources in same directory with tutorials?
// I've decided to leave such cases alone
if (!(name in tutorials)) {
continue;
}
item = conf[name];
current = tutorials[name]
item = conf[name];
current = tutorials[name]
// set title
if (item.title) {
current.title = item.title;
}
// set title
if (item.title) {
current.title = item.title;
}
// add children
if (item.children) {
item.children.forEach(function(child) {
// I really didn't want to throw you an exception in most cases
// but now, user, you pissed me off ;)
if (!(child in tutorials)) {
throw new Error("Missing child tutorial: " + child);
}
// add children
if (item.children) {
item.children.forEach(function(child) {
// I really didn't want to throw you an exception in most cases
// but now, user, you pissed me off ;)
if (!(child in tutorials)) {
throw new Error("Missing child tutorial: " + child);
}
tutorials[child].setParent(current);
});
tutorials[child].setParent(current);
});
}
}
}
};

View File

@ -381,23 +381,25 @@
view.nav = nav;
for (var longname in helper.longnameToUrl) {
var classes = find({kind: 'class', longname: longname});
if (classes.length) { generate('Class: '+classes[0].name, classes, helper.longnameToUrl[longname]); }
if ( hasOwnProp.call(helper.longnameToUrl, longname) ) {
var classes = find({kind: 'class', longname: longname});
if (classes.length) { generate('Class: '+classes[0].name, classes, helper.longnameToUrl[longname]); }
var modules = find({kind: 'module', longname: longname});
if (modules.length) { generate('Module: '+modules[0].name, modules, helper.longnameToUrl[longname]); }
var modules = find({kind: 'module', longname: longname});
if (modules.length) { generate('Module: '+modules[0].name, modules, helper.longnameToUrl[longname]); }
var namespaces = find({kind: 'namespace', longname: longname});
if (namespaces.length) { generate('Namespace: '+namespaces[0].name, namespaces, helper.longnameToUrl[longname]); }
var namespaces = find({kind: 'namespace', longname: longname});
if (namespaces.length) { generate('Namespace: '+namespaces[0].name, namespaces, helper.longnameToUrl[longname]); }
// var constants = find({kind: 'constant', longname: longname});
// if (constants.length) { generate('Constant: '+constants[0].name, constants, helper.longnameToUrl[longname]); }
// var constants = find({kind: 'constant', longname: longname});
// if (constants.length) { generate('Constant: '+constants[0].name, constants, helper.longnameToUrl[longname]); }
var mixins = find({kind: 'mixin', longname: longname});
if (mixins.length) { generate('Mixin: '+mixins[0].name, mixins, helper.longnameToUrl[longname]); }
var mixins = find({kind: 'mixin', longname: longname});
if (mixins.length) { generate('Mixin: '+mixins[0].name, mixins, helper.longnameToUrl[longname]); }
var externals = find({kind: 'external', longname: longname});
if (externals.length) { generate('External: '+externals[0].name, externals, helper.longnameToUrl[longname]); }
var externals = find({kind: 'external', longname: longname});
if (externals.length) { generate('External: '+externals[0].name, externals, helper.longnameToUrl[longname]); }
}
}
if (globals.length) { generate('Global', [{kind: 'globalobj'}], 'global.html'); }