From fbab60e3a80ec91937affa2a0bab4692c3249845 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Sat, 12 Oct 2019 15:30:46 +1030 Subject: [PATCH] Update deps and lint. --- package.json | 18 +++++++++--------- src/index.js | 8 ++++++++ src/lib/helper.js | 1 + src/lib/utils.js | 8 ++++++++ test/conf.spec.js | 1 + test/parse.spec.js | 1 + test/sort.spec.js | 7 +++++++ 7 files changed, 35 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 1e91382..e293843 100644 --- a/package.json +++ b/package.json @@ -28,18 +28,18 @@ "doc" ], "dependencies": { - "bluebird": "^3.5.3", - "fs-extra": "^7.0.1", - "glob": "^7.1.3", - "jsdoc": "^3.5.5", + "bluebird": "^3.7.0", + "fs-extra": "^8.1.0", + "glob": "^7.1.4", + "jsdoc": "^3.6.3", "json-stringify-safe": "^5.0.1", - "lodash": "^4.17.11", - "tmp": "0.0.33" + "lodash": "^4.17.15", + "tmp": "0.1.0" }, "devDependencies": { - "eslint": "^5.9.0", - "eslint-config-xo": "^0.25.0", - "jasmine": "^3.3.0", + "eslint": "^6.5.1", + "eslint-config-xo": "^0.27.1", + "jasmine": "^3.5.0", "jasmine-console-reporter": "^3.1.0", "jsdoc-strip-async-await": "^0.1.0" } diff --git a/src/index.js b/src/index.js index f20d472..ac7deef 100644 --- a/src/index.js +++ b/src/index.js @@ -77,6 +77,7 @@ function buildArgs(options) { if (_.isString(opts.package)) { args.push('-P', opts.package); } + if (opts.recurse) args.push('-r'); if (opts.pedantic) args.push('--pedantic'); if (opts.query) args.push('-q', opts.query); @@ -125,6 +126,7 @@ function normalizeAccess(access) { if (!_.isString(access) && !_.isArray(access)) { return ['public', 'protected']; } + return helper.ensureArray(access); } @@ -177,6 +179,7 @@ function hierarchy(docs, sortType) { // reverse bec. we used eachRight parent.$members.reverse(); } + docs.splice(index, 1); } } @@ -269,6 +272,7 @@ jsdocx.filter = (docs, options, predicate) => { memo.push(symbol); // original symbol pushed } } + return memo; }, []); @@ -277,6 +281,7 @@ jsdocx.filter = (docs, options, predicate) => { } else if (options.sort) { sortDocs(docs, options.sort); } + return docs; }; @@ -317,6 +322,7 @@ jsdocx.parse = (options, callback) => { return opts; }); } + if (hasSource) { return helper.createTempFile(opts.source) .then(file => { @@ -339,6 +345,7 @@ jsdocx.parse = (options, callback) => { if (options.output) { return helper.writeJSON(options.output, docs); } + return docs; }) .catch(err => { @@ -350,6 +357,7 @@ jsdocx.parse = (options, callback) => { err.message = err.message + ' \nExecuted JSDoc Command: ' + cmd + '\n' + 'with JSON configuration: ' + JSON.stringify(conf || {}); } + throw err; }) .nodeify(callback); diff --git a/src/lib/helper.js b/src/lib/helper.js index 8de476e..843a21d 100644 --- a/src/lib/helper.js +++ b/src/lib/helper.js @@ -36,6 +36,7 @@ const helper = { try { out = JSON.parse(string); } catch (e) {} + return out; }, diff --git a/src/lib/utils.js b/src/lib/utils.js index fd1dd06..575e2f8 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -8,6 +8,7 @@ function bracket(prop) { const re = /^[a-z$_][a-z\d$_]*$/i; // non-bracket notation return re.test(prop) ? '.' + prop : '["' + prop + '"]'; } + // fixes a jsdoc bug // e.g. MyClass.Enum."STATE"] —» MyClass.Enum.STATE function fixBracket(notation) { @@ -40,6 +41,7 @@ function notate(obj, notation) { props.shift(); return notate(o, props); } + return o; } @@ -105,6 +107,7 @@ const utils = { const codeName = getMetaCodeName(symbol); if (codeName) return codeName.replace(/.*?[#.~:](\w+)$/i, '$1'); } + return symbol.name; }, @@ -194,10 +197,12 @@ const utils = { && /^".*"$/.test(symbol.memberof) === false) { return cleanName(symbol.memberof); } + longname = cleanName(symbol.$longname); } else { longname = cleanName(symbol); } + // colon (:) is not a level separator. JSDoc uses colon in cases like: // `obj~event:ready` or `module:someModule` if (!longname || !(/[.#~]/g).test(longname)) return ''; @@ -243,11 +248,13 @@ const utils = { || utils.getCodeName(symbol) === name) { return symbol; } + if (symbol.$members) { const sym = utils.getSymbolByName(symbol.$members, name); if (sym) return sym; } } + return null; }, @@ -727,6 +734,7 @@ const utils = { // console.log('comparing:', A, '<<—>>', B, '==>', result); }; } + // grouped sort (by scope). also moving inner symbols to end. return (a, b) => { const A = prop ? a[prop] : a; diff --git a/test/conf.spec.js b/test/conf.spec.js index 83f54ab..0088d70 100644 --- a/test/conf.spec.js +++ b/test/conf.spec.js @@ -142,6 +142,7 @@ describe('JSDoc configuration options', () => { function throwTest() { jsdocx.parse({ files: '' }); } + expect(throwTest).toThrow(); }); diff --git a/test/parse.spec.js b/test/parse.spec.js index 42aa056..71c19f1 100644 --- a/test/parse.spec.js +++ b/test/parse.spec.js @@ -19,6 +19,7 @@ describe('Test: Parser', () => { function throwTest() { jsdocx.parse(undefined); } + expect(throwTest).toThrow(); }); diff --git a/test/sort.spec.js b/test/sort.spec.js index 2aa5e6e..3a41b6d 100644 --- a/test/sort.spec.js +++ b/test/sort.spec.js @@ -25,9 +25,11 @@ function logSortedDocs(docs, nPrefix = '') { console.log(` ${pad(i++, 4)} > prop: ${prop.name}`); }); } + if (Array.isArray(symbol.$members)) { logSortedDocs(symbol.$members, i + '.'); } + i++; }); } @@ -62,6 +64,7 @@ describe('Test: Sorter', () => { 'aGlobalObject2', 'Code', // class 'Code', // constructor + 'Code', // ? 'Code#bProtectedInstanceProp', 'Code.bStaticMethod', 'Code#config', @@ -118,6 +121,7 @@ describe('Test: Sorter', () => { 'aGlobalObject2', // global 'Code', // global 'Code', // global + 'Code', // global 'fGlobalObjExt', // global 'gGlobalArray', // global 'gGlobalArray2', // global @@ -175,6 +179,7 @@ describe('Test: Sorter', () => { 'aGlobalObject2', // public 'Code', // public 'Code', // public + 'Code', // public 'Code.bStaticMethod', // public 'Code#config', // public 'Code#config._opt', // public @@ -234,6 +239,7 @@ describe('Test: Sorter', () => { 'kGlobalObjExt', // constant 'Code', // constructor 'Code', // class + 'Code', // ? 'Code.bStaticMethod', // method 'Code#instanceMethod', // method 'Code.staticMethod', // method @@ -302,6 +308,7 @@ describe('Test: Sorter', () => { 'aGlobalObject2', // global public property 'Code', // global public constructor 'Code', // global public class + 'Code', // global public class 'fGlobalObjExt', // global public property 'gGlobalArray', // global public property 'gGlobalArray2', // global public property