diff --git a/.eslintrc b/.eslintrc index c4840b08b..3e57f2274 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,14 +1,15 @@ { "env": { + "jasmine": true, "node": true }, "rules": { // Possible errors + "no-comma-dangle": 2, "no-cond-assign": 2, "no-console": 0, "no-constant-condition": 0, - "no-comma-dangle": 2, "no-control-regex": 2, "no-debugger": 2, "no-dupe-keys": 2, @@ -19,10 +20,13 @@ "no-extra-parens": 0, "no-extra-semi": 2, "no-func-assign": 2, + "no-inner-declarations": [2, "functions"], "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, "no-negated-in-lhs": 2, "no-obj-calls": 2, "no-regex-spaces": 2, + "no-reserved-keys": 0, "no-sparse-arrays": 2, "no-unreachable": 2, "use-isnan": 2, @@ -34,8 +38,8 @@ "complexity": 0, // TODO: enable "consistent-return": 2, "curly": [2, "all"], + "default-case": 2, "dot-notation": 2, - "eol-last": 2, "eqeqeq": [2, "smart"], "guard-for-in": 2, "no-alert": 2, @@ -45,15 +49,16 @@ "no-empty-label": 2, "no-eq-null": 2, "no-eval": 2, + "no-extra-bind": 2, "no-extend-native": 2, "no-fallthrough": 2, "no-floating-decimal": 2, "no-implied-eval": 2, - "no-labels": 2, "no-iterator": 2, + "no-labels": 2, "no-lone-blocks": 2, "no-loop-func": 2, - "no-mixed-spaces-and-tabs": 2, + "no-multi-spaces": 2, "no-multi-str": 2, "no-native-reassign": 2, "no-new": 2, @@ -61,23 +66,24 @@ "no-new-wrappers": 2, "no-octal": 2, "no-octal-escape": 2, + "no-process-env": 2, "no-proto": 2, "no-redeclare": 2, "no-return-assign": 2, "no-script-url": 2, "no-self-compare": 2, "no-sequences": 2, - "no-trailing-spaces": 2, - "no-undefined": 0, "no-unused-expressions": 2, + "no-void": 2, "no-warning-comments": 0, "no-with": 2, "radix": 2, + "vars-on-top": 0, "wrap-iife": [2, "inside"], "yoda": 2, // Strict mode - "no-global-strict": 0, + "global-strict": 0, "no-extra-strict": 2, "strict": 2, @@ -89,42 +95,66 @@ "no-shadow-restricted-names": 2, "no-undef": 2, "no-undef-init": 2, + "no-undefined": 0, "no-unused-vars": 0, "no-use-before-define": 2, // Node.js "handle-callback-err": 2, "no-mixed-requires": 2, + "no-new-require": 2, "no-path-concat": 2, "no-process-exit": 2, + "no-restricted-modules": 0, "no-sync": 0, // Stylistic issues "brace-style": 0, // TODO: enable with "stroustrup" (or "1tbsp" + lots of cleanup) "camelcase": 2, + "comma-spacing": [2, { + "before": false, + "after": true + }], + "comma-style": [2, "last"], "consistent-this": [2, "self"], - "func-names": 0, // TODO: enable + "eol-last": 2, + "func-names": 0, "func-style": 0, + "key-spacing": [2, { + "beforeColon": false, + "afterColon": true + }], "max-nested-callbacks": 0, "new-cap": 2, "new-parens": 2, - "no-nested-ternary": 2, "no-array-constructor": 2, + "no-lonely-if": 2, + "no-mixed-spaces-and-tabs": 2, + "no-multiple-empty-lines": [2, { + "max": 2 + }], + "no-nested-ternary": 2, "no-new-object": 2, - "no-spaced-func": 2, "no-space-before-semi": 2, + "no-spaced-func": 2, "no-ternary": 0, + "no-trailing-spaces": 2, "no-underscore-dangle": 0, "no-wrap-func": 2, "one-var": 0, + "padded-blocks": [2, "never"], "quotes": [2, "single", "avoid-escape"], "quote-props": 0, "semi": [2, "always"], - "sort-vars": 0, // TODO: enable + "sort-vars": 0, + "space-after-keywords": [2, "always"], + "space-before-blocks": [2, "always"], "space-in-brackets": 0, // TODO: enable? + "space-in-parens": 0, // TODO: enable? "space-infix-ops": 2, "space-return-throw-case": 2, "space-unary-word-ops": 2, + "spaced-line-comment": [2, "always"], "wrap-regex": 0, // Legacy diff --git a/cli.js b/cli.js index 854829d25..35ab99c72 100644 --- a/cli.js +++ b/cli.js @@ -460,5 +460,4 @@ cli.exit = function(exitCode, message) { }; return cli; - })(); diff --git a/lib/jsdoc/name.js b/lib/jsdoc/name.js index 8942c7480..8a4ab814d 100644 --- a/lib/jsdoc/name.js +++ b/lib/jsdoc/name.js @@ -162,18 +162,16 @@ exports.resolve = function(doclet) { doclet.scope = puncToScope[about.scope]; } } - else { - if (doclet.name && doclet.memberof && !doclet.longname) { - if ( REGEXP_LEADING_SCOPE.test(doclet.name) ) { - doclet.scope = puncToScope[RegExp.$1]; - doclet.name = doclet.name.substr(1); - } - else { - doclet.scope = DEFAULT_SCOPE; - } - - doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name); + else if (doclet.name && doclet.memberof && !doclet.longname) { + if ( REGEXP_LEADING_SCOPE.test(doclet.name) ) { + doclet.scope = puncToScope[RegExp.$1]; + doclet.name = doclet.name.substr(1); } + else { + doclet.scope = DEFAULT_SCOPE; + } + + doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name); } if (about.variation) { diff --git a/lib/jsdoc/opts/argparser.js b/lib/jsdoc/opts/argparser.js index b70a45d0c..dd23b588b 100644 --- a/lib/jsdoc/opts/argparser.js +++ b/lib/jsdoc/opts/argparser.js @@ -237,7 +237,6 @@ ArgParser.prototype.parse = function(args, defaults) { // like -t if (arg.charAt(0) === '-') { - // like --template if (arg.charAt(1) === '-') { name = longName = arg.slice(2); diff --git a/lib/jsdoc/plugins.js b/lib/jsdoc/plugins.js index a34fccc25..92fb4947c 100644 --- a/lib/jsdoc/plugins.js +++ b/lib/jsdoc/plugins.js @@ -24,17 +24,17 @@ exports.installPlugins = function(plugins, parser) { plugin = require(plugins[i]); // allow user-defined plugins to... - //...register event handlers + // ...register event handlers if (plugin.handlers) { addHandlers(plugin.handlers, parser); } - //...define tags + // ...define tags if (plugin.defineTags) { plugin.defineTags(dictionary); } - //...add a Rhino node visitor (deprecated in JSDoc 3.3) + // ...add a Rhino node visitor (deprecated in JSDoc 3.3) if (plugin.nodeVisitor) { if ( !parser.addNodeVisitor ) { logger.error('Unable to add the Rhino node visitor from %s, because JSDoc ' + @@ -45,7 +45,7 @@ exports.installPlugins = function(plugins, parser) { } } - //...add a Mozilla Parser API node visitor + // ...add a Mozilla Parser API node visitor if (plugin.astNodeVisitor) { parser.addAstNodeVisitor(plugin.astNodeVisitor); } diff --git a/lib/jsdoc/src/handlers.js b/lib/jsdoc/src/handlers.js index 36a7a61a2..6773e9b4e 100644 --- a/lib/jsdoc/src/handlers.js +++ b/lib/jsdoc/src/handlers.js @@ -220,7 +220,7 @@ function addSymbolMemberof(parser, doclet, astNode) { } else { memberofInfo = parser.astnodeToMemberof(astNode); - if( Array.isArray(memberofInfo) ) { + if ( Array.isArray(memberofInfo) ) { basename = memberofInfo[1]; memberof = memberofInfo[0]; } @@ -283,7 +283,6 @@ function newSymbolDoclet(parser, docletSrc, e) { */ exports.attachTo = function(parser) { // Handle JSDoc "virtual comments" that include one of the following: - // // + A `@name` tag // + Another tag that accepts a name, such as `@function` parser.on('jsdocCommentFound', function(e) { diff --git a/lib/jsdoc/src/parser.js b/lib/jsdoc/src/parser.js index 273d7795d..aa357a122 100644 --- a/lib/jsdoc/src/parser.js +++ b/lib/jsdoc/src/parser.js @@ -36,7 +36,6 @@ var PARSERS = exports.PARSERS = { // TODO: docs exports.createParser = function(type) { - var modulePath; if (!type) { @@ -236,7 +235,6 @@ Parser.prototype._parseSourceCode = function(sourceCode, sourceName) { if (ast) { this._walker.recurse(sourceName, ast, this._visitor); } - } this.emit('fileComplete', e); diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index a9d564350..498de112c 100644 --- a/lib/jsdoc/tag/dictionary/definitions.js +++ b/lib/jsdoc/tag/dictionary/definitions.js @@ -217,9 +217,7 @@ var baseTags = exports.baseTags = { }, // Special separator tag indicating that multiple doclets should be generated for the same // comment. Used internally (and by some JSDoc users, although it's not officially supported). - // // In the following example, the parser will replace `//**` with an `@also` tag: - // // /** // * Foo. // *//** @@ -324,7 +322,7 @@ var baseTags = exports.baseTags = { type = doclet.meta.code.type; value = doclet.meta.code.value; - switch(type) { + switch (type) { case Syntax.ArrayExpression: doclet.defaultvalue = nodeToString(doclet.meta.code.node); doclet.defaultvaluetype = 'array'; diff --git a/lib/jsdoc/tag/type.js b/lib/jsdoc/tag/type.js index 82bae38b9..b9dbe7e0f 100644 --- a/lib/jsdoc/tag/type.js +++ b/lib/jsdoc/tag/type.js @@ -176,7 +176,7 @@ function getTypeStrings(parsedType, isOutermostType) { var TYPES = catharsis.Types; - switch(parsedType.type) { + switch (parsedType.type) { case TYPES.AllLiteral: types.push('*'); break; diff --git a/lib/jsdoc/template.js b/lib/jsdoc/template.js index 5e6113dc8..6c1d4dae3 100644 --- a/lib/jsdoc/template.js +++ b/lib/jsdoc/template.js @@ -29,7 +29,6 @@ exports.Template = function(path) { interpolate: /<\?js=([\s\S]+?)\?>/g, escape: /<\?js~([\s\S]+?)\?>/g }; - }; /** Loads template from given file. diff --git a/lib/jsdoc/util/runtime.js b/lib/jsdoc/util/runtime.js index d435eaecd..1a50a3211 100644 --- a/lib/jsdoc/util/runtime.js +++ b/lib/jsdoc/util/runtime.js @@ -81,7 +81,7 @@ function initializeNode(args) { } exports.initialize = function(args) { - switch(runtime) { + switch (runtime) { case RHINO: initializeRhino(args); break; diff --git a/package.json b/package.json index 886e57e40..e64678ced 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "wrench": "~1.3.9" }, "devDependencies": { + "eslint": "~0.9.1", "gulp": "~3.8.5", "gulp-eslint": "~0.1.7", "gulp-json-editor": "~2.0.2", diff --git a/plugins/commentConvert.js b/plugins/commentConvert.js index 5c349bfed..64347e0d9 100644 --- a/plugins/commentConvert.js +++ b/plugins/commentConvert.js @@ -5,6 +5,8 @@ */ 'use strict'; +/*eslint spaced-line-comment: 0 */ + exports.handlers = { /// /// Convert ///-style comments into jsdoc comments. diff --git a/plugins/partial.js b/plugins/partial.js index e53f44154..9b5171579 100644 --- a/plugins/partial.js +++ b/plugins/partial.js @@ -1,4 +1,3 @@ -/*global env: true */ /** @overview Adds support for reusable partial jsdoc files. @module plugins/partial @@ -10,21 +9,21 @@ var fs = require('jsdoc/fs'); var path = require('path'); exports.handlers = { - /// - /// Include a partial jsdoc - /// @param e - /// @param e.filename - /// @param e.source - /// - /// @example - /// @partial "partial_doc.jsdoc" - /// + /** + * Include a partial jsdoc + * + * @param e + * @param e.filename + * @param e.source + * @example + * @partial "partial_doc.jsdoc" + */ beforeParse: function(e) { e.source = e.source.replace(/(@partial \".*\")+/g, function($) { var pathArg = $.match(/\".*\"/)[0].replace(/"/g,''); var fullPath = path.join(e.filename , '..', pathArg); - var partialData = fs.readFileSync(fullPath, env.opts.encoding); + var partialData = fs.readFileSync(fullPath, global.env.opts.encoding); return partialData; }); diff --git a/plugins/sourcetag.js b/plugins/sourcetag.js index 23854269a..c773283d8 100644 --- a/plugins/sourcetag.js +++ b/plugins/sourcetag.js @@ -23,7 +23,6 @@ exports.handlers = { tag, value; - //console.log(e.doclet); // any user-defined tags in this doclet? if (typeof tags !== 'undefined') { // only interested in the @source tags diff --git a/templates/haruki/publish.js b/templates/haruki/publish.js index cf9ec01aa..657c85917 100644 --- a/templates/haruki/publish.js +++ b/templates/haruki/publish.js @@ -197,7 +197,6 @@ function graft(parentNode, childNodes, parentLongname, parentName) { @param {object} opts */ exports.publish = function(data, opts) { - var root = {}, docs; @@ -218,5 +217,4 @@ exports.publish = function(data, opts) { else { console.log('This template only supports output to the console. Use the option "-d console" when you run JSDoc.'); } - };