From ff62a9099ddf959b84c911d913db321faadaf66b Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Tue, 10 Jul 2012 06:43:19 -0700 Subject: [PATCH] disable JSHint's "shadow" relaxing option --- .jshintrc | 2 +- rhino_modules/fs.js | 2 +- rhino_modules/jsdoc/config.js | 2 +- rhino_modules/jsdoc/name.js | 13 ++++++----- rhino_modules/jsdoc/src/parser.js | 26 +++++++++++++--------- rhino_modules/jsdoc/tag.js | 4 ++-- rhino_modules/jsdoc/util/templateHelper.js | 12 +++++----- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.jshintrc b/.jshintrc index 4021e2cf..15cec50d 100644 --- a/.jshintrc +++ b/.jshintrc @@ -35,7 +35,7 @@ "proto": false, "regexdash": false, "scripturl": true, - "shadow": true, + "shadow": false, "smarttabs": true, "sub": true, "supernew": true, diff --git a/rhino_modules/fs.js b/rhino_modules/fs.js index 2dec03be..a32eff3b 100644 --- a/rhino_modules/fs.js +++ b/rhino_modules/fs.js @@ -131,7 +131,7 @@ exports.copyFile = function(inFile, outDir, fileName) { outDir = toDir(outDir); - var inFile = new java.io.File(inFile); + inFile = new java.io.File(inFile); var outFile = new java.io.File(outDir+'/'+fileName); var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096); diff --git a/rhino_modules/jsdoc/config.js b/rhino_modules/jsdoc/config.js index df09691e..61b39253 100644 --- a/rhino_modules/jsdoc/config.js +++ b/rhino_modules/jsdoc/config.js @@ -27,7 +27,7 @@ const defaults = { @param {string} [json] - The contents of config.json. */ function Config(json) { - var json = JSON.parse( (json || "{}") ); + json = JSON.parse( (json || "{}") ); this._config = util.mergeRecurse(defaults, json); } diff --git a/rhino_modules/jsdoc/name.js b/rhino_modules/jsdoc/name.js index 5c8f2dc7..d3d73b40 100644 --- a/rhino_modules/jsdoc/name.js +++ b/rhino_modules/jsdoc/name.js @@ -123,8 +123,8 @@ RegExp.escape = RegExp.escape || function(str) { */ exports.applyNamespace = function(longname, ns) { var nameParts = exports.shorten(longname), - name = nameParts.name, - longname = nameParts.longname; + name = nameParts.name; + longname = nameParts.longname; if ( !/^[a-zA-Z]+?:.+$/i.test(name) ) { longname = longname.replace( new RegExp(RegExp.escape(name)+'$'), ns + ':' + name ); @@ -161,21 +161,22 @@ exports.shorten = function(longname, forcedMemberof) { var name = '', scope = '', // ., ~, or # memberof = '', + parts, variation; longname = longname.replace( /\.prototype\.?/g, '#' ); if (typeof forcedMemberof !== 'undefined') { name = longname.substr(forcedMemberof.length); - var parts = forcedMemberof.match(/^(.*?)([#.~]?)$/); + parts = forcedMemberof.match(/^(.*?)([#.~]?)$/); if (parts[1]) { memberof = parts[1] || forcedMemberof; } if (parts[2]) { scope = parts[2]; } } else { - var parts = longname? - (longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ) || []).reverse() - : ['']; + parts = longname? + (longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ) || []).reverse() + : ['']; name = parts[0] || ''; // ensure name is always initialised to avoid error being thrown when calling replace on undefined [gh-24] scope = parts[1] || ''; // ., ~, or # diff --git a/rhino_modules/jsdoc/src/parser.js b/rhino_modules/jsdoc/src/parser.js index 4c553553..c6db6a43 100644 --- a/rhino_modules/jsdoc/src/parser.js +++ b/rhino_modules/jsdoc/src/parser.js @@ -303,6 +303,9 @@ function visitNode(node) { nodeComments, comment, commentSrc, + basename, + func, + funcDoc, i, l; @@ -342,7 +345,7 @@ function visitNode(node) { finishers: [currentParser.addDocletRef] }; - var basename = getBasename(e.code.name); + basename = getBasename(e.code.name); if (basename !== 'this') { e.code.funcscope = currentParser.resolveVar(node, basename); @@ -384,8 +387,8 @@ function visitNode(node) { }; // keep track of vars in a function or global scope - var func = "__global__", - funcDoc = null; + func = "__global__"; + funcDoc = null; if (node.enclosingFunction) { func = 'astnode'+node.enclosingFunction.hashCode(); } @@ -412,8 +415,8 @@ function visitNode(node) { //console.log(':: e.code.name is', e.code.name); // keep track of vars in a function or global scope - var func = "__global__", - funcDoc = null; + func = "__global__"; + funcDoc = null; if (node.enclosingFunction) { func = 'astnode'+node.enclosingFunction.hashCode(); } @@ -424,12 +427,12 @@ function visitNode(node) { e.finishers.push(makeVarsFinisher(funcDoc)); } - var basename = getBasename(e.code.name); + basename = getBasename(e.code.name); e.code.funcscope = currentParser.resolveVar(node, basename); } if (!e) { e = {finishers: []}; } - for(var i = 0, l = currentParser._visitors.length; i < l; i++) { + for(i = 0, l = currentParser._visitors.length; i < l; i++) { currentParser._visitors[i].visitNode(node, e, currentParser, currentSourceName); if (e.stopPropagation) { break; } } @@ -438,7 +441,7 @@ function visitNode(node) { currentParser.fire(e.event, e, currentParser); } - for (var i = 0, l = e.finishers.length; i < l; i++) { + for (i = 0, l = e.finishers.length; i < l; i++) { e.finishers[i].call(currentParser, e); } @@ -478,7 +481,8 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) { */ exports.Parser.prototype.astnodeToMemberof = function(node) { var id, - doclet; + doclet, + alias; if (node.type === Token.VAR || node.type === Token.FUNCTION || node.type == tkn.NAMEDFUNCTIONSTATEMENT) { if (node.enclosingFunction) { // an inner var or func @@ -498,7 +502,7 @@ exports.Parser.prototype.astnodeToMemberof = function(node) { id = 'astnode'+scope.enclosingFunction.hashCode(); doclet = this.refs[id]; if (doclet && doclet.meta.vars && basename in doclet.meta.vars) { - var alias = hasOwnProp.call(doclet.meta.vars, basename)? doclet.meta.vars[basename] : false; + alias = hasOwnProp.call(doclet.meta.vars, basename)? doclet.meta.vars[basename] : false; if (alias !== false) { return [alias, basename]; } @@ -509,7 +513,7 @@ exports.Parser.prototype.astnodeToMemberof = function(node) { //First check to see if we have a global scope alias doclet = this.refs["__global__"]; if (doclet && doclet.meta.vars && hasOwnProp.call(doclet.meta.vars, basename)) { - var alias = doclet.meta.vars[basename]; + alias = doclet.meta.vars[basename]; if (alias !== false) { return [alias, basename]; } diff --git a/rhino_modules/jsdoc/tag.js b/rhino_modules/jsdoc/tag.js index 56caa3a7..d404b2e8 100644 --- a/rhino_modules/jsdoc/tag.js +++ b/rhino_modules/jsdoc/tag.js @@ -70,8 +70,8 @@ function parseParamText(tagText) { @param {object=} meta */ exports.Tag = function(tagTitle, tagBody, meta) { - var tagDef = jsdoc.tag.dictionary.lookUp(tagTitle), - meta = meta || {}; + var tagDef = jsdoc.tag.dictionary.lookUp(tagTitle); + meta = meta || {}; this.originalTitle = trim(tagTitle); diff --git a/rhino_modules/jsdoc/util/templateHelper.js b/rhino_modules/jsdoc/util/templateHelper.js index fe5e3106..f30edaf0 100644 --- a/rhino_modules/jsdoc/util/templateHelper.js +++ b/rhino_modules/jsdoc/util/templateHelper.js @@ -129,17 +129,19 @@ exports.resolveLinks = function(str) { /** Turn a doclet into a URL. */ exports.createLink = function(doclet) { - var url = ''; + var url = '', + longname, + filename; if (containers.indexOf(doclet.kind) < 0) { - var longname = doclet.longname, - filename = strToFilename(doclet.memberof || exports.globalName); + longname = doclet.longname; + filename = strToFilename(doclet.memberof || exports.globalName); url = filename + exports.fileExtension + '#' + getNamespace(doclet.kind) + doclet.name; } else { - var longname = doclet.longname, - filename = strToFilename(longname); + longname = doclet.longname; + filename = strToFilename(longname); url = filename + exports.fileExtension; }