diff --git a/index.js b/index.js index e3b6ba8..7e42753 100644 --- a/index.js +++ b/index.js @@ -7,12 +7,12 @@ const addInherited = require('jsdoc/augment').addInherited; // eslint-disable-li const config = env.conf.typescript; if (!config) { throw new Error( - 'Configuration "typescript" for jsdoc-plugin-typescript missing.' + 'Configuration "typescript" for jsdoc-plugin-typescript missing.', ); } if (!('moduleRoot' in config)) { throw new Error( - 'Configuration "typescript.moduleRoot" for jsdoc-plugin-typescript missing.' + 'Configuration "typescript.moduleRoot" for jsdoc-plugin-typescript missing.', ); } const moduleRoot = config.moduleRoot; @@ -21,7 +21,7 @@ if (!fs.existsSync(moduleRootAbsolute)) { throw new Error( 'Directory "' + moduleRootAbsolute + - '" does not exist. Check the "typescript.moduleRoot" config option for jsdoc-plugin-typescript' + '" does not exist. Check the "typescript.moduleRoot" config option for jsdoc-plugin-typescript', ); } @@ -47,7 +47,7 @@ function getModuleInfo(moduleId, extension, parser) { const absolutePath = path.join( process.cwd(), moduleRoot, - moduleId + extension + moduleId + extension, ); if (!fs.existsSync(absolutePath)) { return null; @@ -186,7 +186,7 @@ exports.defineTags = function (dictionary) { // Bracket notation to dot notation .replace( /(\w+|>|\)|\])\[(?:'([^']+)'|"([^"]+)")\]/g, - '$1.$2$3' + '$1.$2$3', ); return head + replaced + tail; @@ -293,10 +293,10 @@ exports.astNodeVisitor = { if ( leadingComments.length === 0 || (leadingComments[leadingComments.length - 1].value.indexOf( - '@classdesc' + '@classdesc', ) === -1 && noClassdescRegEx.test( - leadingComments[leadingComments.length - 1].value + leadingComments[leadingComments.length - 1].value, )) ) { // Create a suitable comment node if we don't have one on the class yet @@ -314,7 +314,7 @@ exports.astNodeVisitor = { if (node.superClass) { // Remove the `@extends` tag because JSDoc does not does not handle generic type. (`@extends {Base}`) const extendsIndex = lines.findIndex((line) => - line.includes('@extends') + line.includes('@extends'), ); if (extendsIndex !== -1) { lines.splice(extendsIndex, 1); @@ -326,7 +326,7 @@ exports.astNodeVisitor = { if (identifier) { const absolutePath = path.resolve( path.dirname(currentSourceName), - identifier.value + identifier.value, ); // default to js extension since .js extention is assumed implicitly const extension = getExtension(absolutePath); @@ -359,7 +359,7 @@ exports.astNodeVisitor = { // Replace typeof Foo with Class comment.value = comment.value.replace( /typeof ([^,\|\}\>]*)([,\|\}\>])/g, - 'Class<$1>$2' + 'Class<$1>$2', ); // Remove `@override` annotations to avoid JSDoc breaking the inheritance chain @@ -387,7 +387,7 @@ exports.astNodeVisitor = { if (replaceAttempt > 100) { // infinite loop protection throw new Error( - `Invalid docstring ${comment.value} in ${currentSourceName}.` + `Invalid docstring ${comment.value} in ${currentSourceName}.`, ); } } else { @@ -396,7 +396,7 @@ exports.astNodeVisitor = { lastImportPath = importExpression; const rel = path.resolve( path.dirname(currentSourceName), - importSource + importSource, ); // default to js extension since .js extention is assumed implicitly const extension = getExtension(rel); @@ -420,7 +420,7 @@ exports.astNodeVisitor = { if (replacement) { comment.value = comment.value.replace( importExpression, - replacement + remainder + replacement + remainder, ); } } @@ -441,13 +441,13 @@ exports.astNodeVisitor = { Object.keys(identifiers).forEach((key) => { const eventRegex = new RegExp( `@(event |fires )${key}([^A-Za-z])`, - 'g' + 'g', ); replace(eventRegex); const typeRegex = new RegExp( `@(.*[{<|,(!?:]\\s*)${key}([^A-Za-z].*?\}|\})`, - 'g' + 'g', ); replace(typeRegex); @@ -456,7 +456,7 @@ exports.astNodeVisitor = { const identifier = identifiers[key]; const absolutePath = path.resolve( path.dirname(currentSourceName), - identifier.value + identifier.value, ); // default to js extension since .js extention is assumed implicitly const extension = getExtension(absolutePath); @@ -472,11 +472,11 @@ exports.astNodeVisitor = { : getDelimiter(moduleId, exportName, parser); const replacement = `module:${moduleId.replace( slashRegEx, - '/' + '/', )}${exportName ? delimiter + exportName : ''}`; comment.value = comment.value.replace( regex, - '@$1' + replacement + '$2' + '@$1' + replacement + '$2', ); } }