From f94d6645c41a1a3d1e10beeb8412fdf2ede39a56 Mon Sep 17 00:00:00 2001 From: Vincent Ogloblinsky Date: Wed, 16 Jan 2019 11:28:58 +0100 Subject: [PATCH] fix(app): linting issues --- src/app/application.ts | 45 +++++++------ src/app/compiler/angular-dependencies.ts | 26 ++++---- .../angular/deps/helpers/component-helper.ts | 3 +- src/app/compiler/angularjs-dependencies.ts | 4 +- src/app/configuration.ts | 8 ++- src/app/engines/components-tree.engine.ts | 5 +- src/app/engines/dependencies.engine.ts | 34 ++++++---- src/app/engines/export-json.engine.ts | 10 ++- src/app/engines/html.engine.helpers.ts | 46 ++++++------- src/app/engines/html.engine.ts | 10 +-- src/app/engines/i18n.engine.ts | 4 +- src/app/engines/markdown.engine.ts | 3 +- src/app/engines/search.engine.ts | 6 +- .../configuration-file.interface.ts | 46 +++++++++++++ src/app/interfaces/coverageData.interface.ts | 3 + src/app/interfaces/jsdoc-tag.interface.ts | 12 ++-- src/app/interfaces/main-data.interface.ts | 4 +- src/app/nodes/angular-ngmodule-node.ts | 1 + src/index-cli.ts | 3 +- src/utils/extends-merger.util.ts | 3 +- src/utils/imports.util.ts | 2 +- src/utils/jsdoc-parser.util.ts | 2 +- src/utils/router-parser.util.ts | 7 +- src/utils/utils.ts | 64 ++++++++++--------- 24 files changed, 213 insertions(+), 138 deletions(-) create mode 100644 src/app/interfaces/configuration-file.interface.ts create mode 100644 src/app/interfaces/coverageData.interface.ts diff --git a/src/app/application.ts b/src/app/application.ts index 08ae883d..18b9fffd 100644 --- a/src/app/application.ts +++ b/src/app/application.ts @@ -1,7 +1,7 @@ import * as fs from 'fs-extra'; -import * as path from 'path'; import * as LiveServer from 'live-server'; import * as _ from 'lodash'; +import * as path from 'path'; import { SyntaxKind } from 'ts-simple-ast'; @@ -10,32 +10,34 @@ const marked = require('marked'); const traverse = require('traverse'); import { logger } from '../utils/logger'; + +import Configuration from './configuration'; + +import DependenciesEngine from './engines/dependencies.engine'; +import ExportEngine from './engines/export.engine'; +import FileEngine from './engines/file.engine'; import HtmlEngine from './engines/html.engine'; +import I18nEngine from './engines/i18n.engine'; import MarkdownEngine from './engines/markdown.engine'; -import FileEngine from './engines/file.engine'; -import Configuration from './configuration'; import NgdEngine from './engines/ngd.engine'; import SearchEngine from './engines/search.engine'; -import ExportEngine from './engines/export.engine'; -import I18nEngine from './engines/i18n.engine'; import { AngularDependencies } from './compiler/angular-dependencies'; import { AngularJSDependencies } from './compiler/angularjs-dependencies'; -import { COMPODOC_DEFAULTS } from '../utils/defaults'; +import AngularVersionUtil from '../utils/angular-version.util'; import { COMPODOC_CONSTANTS } from '../utils/constants'; +import { COMPODOC_DEFAULTS } from '../utils/defaults'; +import { promiseSequential } from '../utils/promise-sequential'; +import RouterParserUtil from '../utils/router-parser.util'; import { - findMainSourceFolder, cleanNameWithoutSpaceAndToLowerCase, - cleanSourcesForWatch + cleanSourcesForWatch, + findMainSourceFolder } from '../utils/utils'; -import { promiseSequential } from '../utils/promise-sequential'; -import DependenciesEngine from './engines/dependencies.engine'; -import RouterParserUtil from '../utils/router-parser.util'; - -import AngularVersionUtil from '../utils/angular-version.util'; +import { CoverageData } from './interfaces/coverageData.interface'; let cwd = process.cwd(); let startTime = new Date(); @@ -745,18 +747,17 @@ export class Application { const parsedSummaryData = JSON.parse(summaryData); - let that = this, - level = 0; + let that = this; traverse(parsedSummaryData).forEach(function() { if (this.notRoot && typeof this.node === 'object') { let rawPath = this.path; - let file = this.node['file']; - let title = this.node['title']; + let file = this.node.file; + let title = this.node.title; let finalPath = Configuration.mainData.includesFolder; let finalDepth = rawPath.filter(el => { - return !isNaN(parseInt(el)); + return !isNaN(parseInt(el, 10)); }); if (typeof file !== 'undefined' && typeof title !== 'undefined') { @@ -769,7 +770,7 @@ export class Application { ? parsedSummaryData : lastElementRootTree; if (typeof elementTree.children !== 'undefined') { - elementTree = elementTree['children'][el]; + elementTree = elementTree.children[el]; } else { elementTree = elementTree[el]; } @@ -2310,11 +2311,13 @@ at least one config for the 'info' or 'source' tab in --navTabConfig.`); return new Promise((resolve, reject) => { let covDat, covFileNames; - if (!Configuration.mainData.coverageData['files']) { + let coverageData: CoverageData = Configuration.mainData.coverageData; + + if (!coverageData.files) { logger.warn('Missing documentation coverage data'); } else { covDat = {}; - covFileNames = _.map(Configuration.mainData.coverageData['files'], el => { + covFileNames = _.map(coverageData.files, el => { let fileName = el.filePath; covDat[fileName] = { type: el.type, diff --git a/src/app/compiler/angular-dependencies.ts b/src/app/compiler/angular-dependencies.ts index 05d6bf3d..1ca19b1e 100644 --- a/src/app/compiler/angular-dependencies.ts +++ b/src/app/compiler/angular-dependencies.ts @@ -3,9 +3,9 @@ import * as path from 'path'; import * as _ from 'lodash'; import Ast, { ts, SyntaxKind } from 'ts-simple-ast'; -import { logger } from '../../utils/logger'; -import { markedtags, mergeTagsAndArgs, cleanLifecycleHooksFromMethods } from '../../utils/utils'; import { kindToType } from '../../utils/kind-to-type'; +import { logger } from '../../utils/logger'; +import { cleanLifecycleHooksFromMethods, markedtags, mergeTagsAndArgs } from '../../utils/utils'; import ComponentsTreeEngine from '../engines/components-tree.engine'; import { FrameworkDependencies } from './framework-dependencies'; @@ -13,10 +13,10 @@ import { FrameworkDependencies } from './framework-dependencies'; import ImportsUtil from '../../utils/imports.util'; import { - JsdocParserUtil, - isModuleWithProviders, getModuleWithProviders, - isIgnore + isIgnore, + isModuleWithProviders, + JsdocParserUtil } from '../../utils'; import ExtendsMerger from '../../utils/extends-merger.util'; @@ -25,24 +25,24 @@ import RouterParserUtil from '../../utils/router-parser.util'; import { CodeGenerator } from './angular/code-generator'; -import { DirectiveDepFactory } from './angular/deps/directive-dep.factory'; -import { ComponentCache } from './angular/deps/helpers/component-helper'; -import { ModuleDepFactory } from './angular/deps/module-dep.factory'; import { ComponentDepFactory } from './angular/deps/component-dep.factory'; import { ControllerDepFactory } from './angular/deps/controller-dep.factory'; -import { ModuleHelper } from './angular/deps/helpers/module-helper'; +import { DirectiveDepFactory } from './angular/deps/directive-dep.factory'; +import { ComponentCache } from './angular/deps/helpers/component-helper'; import { JsDocHelper } from './angular/deps/helpers/js-doc-helper'; +import { ModuleHelper } from './angular/deps/helpers/module-helper'; import { SymbolHelper } from './angular/deps/helpers/symbol-helper'; +import { ModuleDepFactory } from './angular/deps/module-dep.factory'; import Configuration from '../configuration'; import { - IInjectableDep, - IPipeDep, IDep, - IInterfaceDep, - IFunctionDecDep, IEnumDecDep, + IFunctionDecDep, + IInjectableDep, + IInterfaceDep, + IPipeDep, ITypeAliasDecDep } from './angular/dependencies.interfaces'; diff --git a/src/app/compiler/angular/deps/helpers/component-helper.ts b/src/app/compiler/angular/deps/helpers/component-helper.ts index d67426cc..516af904 100644 --- a/src/app/compiler/angular/deps/helpers/component-helper.ts +++ b/src/app/compiler/angular/deps/helpers/component-helper.ts @@ -1,8 +1,7 @@ import { ts } from 'ts-simple-ast'; -import { SymbolHelper, IParseDeepIdentifierResult } from './symbol-helper'; import { detectIndent } from '../../../../../utils'; -import { IDep, Deps } from '../../dependencies.interfaces'; import { ClassHelper } from './class-helper'; +import { IParseDeepIdentifierResult, SymbolHelper } from './symbol-helper'; export class ComponentHelper { constructor( diff --git a/src/app/compiler/angularjs-dependencies.ts b/src/app/compiler/angularjs-dependencies.ts index bbf4c0b2..29af05e9 100644 --- a/src/app/compiler/angularjs-dependencies.ts +++ b/src/app/compiler/angularjs-dependencies.ts @@ -1,8 +1,8 @@ -import { FrameworkDependencies } from './framework-dependencies'; import { ComponentCache } from './angular/deps/helpers/component-helper'; -import { ModuleHelper } from './angular/deps/helpers/module-helper'; import { JsDocHelper } from './angular/deps/helpers/js-doc-helper'; +import { ModuleHelper } from './angular/deps/helpers/module-helper'; import { SymbolHelper } from './angular/deps/helpers/symbol-helper'; +import { FrameworkDependencies } from './framework-dependencies'; export class AngularJSDependencies extends FrameworkDependencies { private engine: any; diff --git a/src/app/configuration.ts b/src/app/configuration.ts index c76b6393..60811165 100644 --- a/src/app/configuration.ts +++ b/src/app/configuration.ts @@ -1,8 +1,10 @@ +import * as _ from 'lodash'; + import { COMPODOC_DEFAULTS } from '../utils/defaults'; -import { PageInterface } from './interfaces/page.interface'; -import { MainDataInterface } from './interfaces/main-data.interface'; + import { ConfigurationInterface } from './interfaces/configuration.interface'; -import * as _ from 'lodash'; +import { MainDataInterface } from './interfaces/main-data.interface'; +import { PageInterface } from './interfaces/page.interface'; export class Configuration implements ConfigurationInterface { private _pages: PageInterface[] = []; diff --git a/src/app/engines/components-tree.engine.ts b/src/app/engines/components-tree.engine.ts index b942d269..6dd2c501 100644 --- a/src/app/engines/components-tree.engine.ts +++ b/src/app/engines/components-tree.engine.ts @@ -1,7 +1,8 @@ -import * as path from 'path'; import * as _ from 'lodash'; -import FileEngine from './file.engine'; +import * as path from 'path'; + import { logger } from '../../utils/logger'; +import FileEngine from './file.engine'; const $: any = require('cheerio'); diff --git a/src/app/engines/dependencies.engine.ts b/src/app/engines/dependencies.engine.ts index a2b38979..158bec3c 100644 --- a/src/app/engines/dependencies.engine.ts +++ b/src/app/engines/dependencies.engine.ts @@ -1,26 +1,28 @@ import * as _ from 'lodash'; -import { ParsedData } from '../interfaces/parsed-data.interface'; import { MiscellaneousData } from '../interfaces/miscellaneous-data.interface'; - -import { getNamesCompareFn } from '../../utils/utils'; -import { IModuleDep } from '../compiler/angular/deps/module-dep.factory'; -import { IComponentDep } from '../compiler/angular/deps/component-dep.factory'; -import { IDirectiveDep } from '../compiler/angular/deps/directive-dep.factory'; -import { IApiSourceResult } from '../../utils/api-source-result.interface'; +import { ParsedData } from '../interfaces/parsed-data.interface'; import { RouteInterface } from '../interfaces/routes.interface'; + import AngularApiUtil from '../../utils/angular-api.util'; +import { IApiSourceResult } from '../../utils/api-source-result.interface'; +import { getNamesCompareFn } from '../../utils/utils'; + import { + IEnumDecDep, + IFunctionDecDep, + IGuardDep, IInjectableDep, + IInterceptorDep, IInterfaceDep, IPipeDep, - ITypeAliasDecDep, - IFunctionDecDep, - IEnumDecDep, - IInterceptorDep, - IGuardDep + ITypeAliasDecDep } from '../compiler/angular/dependencies.interfaces'; + +import { IComponentDep } from '../compiler/angular/deps/component-dep.factory'; import { IControllerDep } from '../compiler/angular/deps/controller-dep.factory'; +import { IDirectiveDep } from '../compiler/angular/deps/directive-dep.factory'; +import { IModuleDep } from '../compiler/angular/deps/module-dep.factory'; const traverse = require('traverse'); @@ -104,8 +106,12 @@ export class DependenciesEngine { public init(data: ParsedData) { traverse(data).forEach(function(node) { if (node) { - if (node.parent) delete node.parent; - if (node.initializer) delete node.initializer; + if (node.parent) { + delete node.parent; + } + if (node.initializer) { + delete node.initializer; + } } }); this.rawData = data; diff --git a/src/app/engines/export-json.engine.ts b/src/app/engines/export-json.engine.ts index a7365f24..5dd6fd98 100644 --- a/src/app/engines/export-json.engine.ts +++ b/src/app/engines/export-json.engine.ts @@ -25,8 +25,12 @@ export class ExportJsonEngine { traverse(data).forEach(function(node) { if (node) { - if (node.parent) delete node.parent; - if (node.initializer) delete node.initializer; + if (node.parent) { + delete node.parent; + } + if (node.initializer) { + delete node.initializer; + } } }); @@ -43,7 +47,7 @@ export class ExportJsonEngine { return FileEngine.write( outputFolder + path.sep + '/documentation.json', - JSON.stringify(exportData, null, 4) + JSON.stringify(exportData, undefined, 4) ).catch(err => { logger.error('Error during export file generation ', err); return Promise.reject(err); diff --git a/src/app/engines/html.engine.helpers.ts b/src/app/engines/html.engine.helpers.ts index 8d3c2c5d..37f8394a 100644 --- a/src/app/engines/html.engine.helpers.ts +++ b/src/app/engines/html.engine.helpers.ts @@ -1,40 +1,40 @@ import * as Handlebars from 'handlebars'; import * as _ from 'lodash'; -import { IHtmlEngineHelper } from './html-engine-helpers/html-engine-helper.interface'; +import { BreakCommaHelper } from './html-engine-helpers/break-comma.helper'; +import { BreakLinesHelper } from './html-engine-helpers/break-lines.helper'; +import { CleanParagraphHelper } from './html-engine-helpers/clean-paragraph.helper'; import { CompareHelper } from './html-engine-helpers/compare.helper'; -import { OrHelper } from './html-engine-helpers/or.helper'; +import { DebugHelper } from './html-engine-helpers/debug.helper'; +import { ElementAloneHelper } from './html-engine-helpers/element-alone.helper'; +import { EscapeSimpleQuoteHelper } from './html-engine-helpers/escape-simple-quote.helper'; +import { FilterAngular2ModulesHelper } from './html-engine-helpers/filter-angular2-modules.helper'; import { FunctionSignatureHelper } from './html-engine-helpers/function-signature.helper'; -import { IsNotToggleHelper } from './html-engine-helpers/is-not-toggle.helper'; +import { HasOwnHelper } from './html-engine-helpers/has-own.helper'; +import { IHtmlEngineHelper } from './html-engine-helpers/html-engine-helper.interface'; +import { I18nHelper } from './html-engine-helpers/i18n.helper'; +import { IfStringHelper } from './html-engine-helpers/if-string.helper'; +import { IndexableSignatureHelper } from './html-engine-helpers/indexable-signature.helper'; import { IsInitialTabHelper } from './html-engine-helpers/is-initial-tab.helper'; +import { IsNotToggleHelper } from './html-engine-helpers/is-not-toggle.helper'; import { IsTabEnabledHelper } from './html-engine-helpers/is-tab-enabled.helper'; -import { IfStringHelper } from './html-engine-helpers/if-string.helper'; -import { OrLengthHelper } from './html-engine-helpers/or-length.helper'; -import { FilterAngular2ModulesHelper } from './html-engine-helpers/filter-angular2-modules.helper'; -import { DebugHelper } from './html-engine-helpers/debug.helper'; -import { BreakLinesHelper } from './html-engine-helpers/break-lines.helper'; -import { CleanParagraphHelper } from './html-engine-helpers/clean-paragraph.helper'; -import { EscapeSimpleQuoteHelper } from './html-engine-helpers/escape-simple-quote.helper'; -import { BreakCommaHelper } from './html-engine-helpers/break-comma.helper'; -import { ModifKindHelper } from './html-engine-helpers/modif-kind-helper'; -import { ModifIconHelper } from './html-engine-helpers/modif-icon.helper'; -import { RelativeURLHelper } from './html-engine-helpers/relative-url.helper'; -import { JsdocReturnsCommentHelper } from './html-engine-helpers/jsdoc-returns-comment.helper'; import { JsdocCodeExampleHelper } from './html-engine-helpers/jsdoc-code-example.helper'; +import { JsdocDefaultHelper } from './html-engine-helpers/jsdoc-default.helper'; import { JsdocExampleHelper } from './html-engine-helpers/jsdoc-example.helper'; -import { JsdocParamsHelper } from './html-engine-helpers/jsdoc-params.helper'; import { JsdocParamsValidHelper } from './html-engine-helpers/jsdoc-params-valid.helper'; -import { JsdocDefaultHelper } from './html-engine-helpers/jsdoc-default.helper'; +import { JsdocParamsHelper } from './html-engine-helpers/jsdoc-params.helper'; +import { JsdocReturnsCommentHelper } from './html-engine-helpers/jsdoc-returns-comment.helper'; import { LinkTypeHelper } from './html-engine-helpers/link-type.helper'; -import { IndexableSignatureHelper } from './html-engine-helpers/indexable-signature.helper'; -import { ObjectHelper } from './html-engine-helpers/object.helper'; +import { ModifIconHelper } from './html-engine-helpers/modif-icon.helper'; +import { ModifKindHelper } from './html-engine-helpers/modif-kind-helper'; import { ObjectLengthHelper } from './html-engine-helpers/object-length.helper'; -import { ParseDescriptionHelper } from './html-engine-helpers/parse-description.helper'; +import { ObjectHelper } from './html-engine-helpers/object.helper'; import { OneParameterHasHelper } from './html-engine-helpers/one-parameter-has.helper'; -import { ElementAloneHelper } from './html-engine-helpers/element-alone.helper'; -import { HasOwnHelper } from './html-engine-helpers/has-own.helper'; +import { OrLengthHelper } from './html-engine-helpers/or-length.helper'; +import { OrHelper } from './html-engine-helpers/or.helper'; +import { ParseDescriptionHelper } from './html-engine-helpers/parse-description.helper'; +import { RelativeURLHelper } from './html-engine-helpers/relative-url.helper'; import { ShortURLHelper } from './html-engine-helpers/short-url.helper'; -import { I18nHelper } from './html-engine-helpers/i18n.helper'; export class HtmlEngineHelpers { public registerHelpers(bars): void { diff --git a/src/app/engines/html.engine.ts b/src/app/engines/html.engine.ts index 9cdc2eb9..dcc730ca 100644 --- a/src/app/engines/html.engine.ts +++ b/src/app/engines/html.engine.ts @@ -1,23 +1,20 @@ -import * as path from 'path'; import * as Handlebars from 'handlebars'; +import * as path from 'path'; import { logger } from '../../utils/logger'; -import { HtmlEngineHelpers } from './html.engine.helpers'; -import Configuration from '../configuration'; import FileEngine from './file.engine'; +import { HtmlEngineHelpers } from './html.engine.helpers'; export class HtmlEngine { private cache: { page: string } = {} as any; private compiledPage; private precompiledMenu; - private compiledMobileMenu; - private compiledMenu; private static instance: HtmlEngine; private constructor() { const helper = new HtmlEngineHelpers(); - helper.registerHelpers(Handlebars, Configuration); + helper.registerHelpers(Handlebars); } public static getInstance() { if (!HtmlEngine.instance) { @@ -79,7 +76,6 @@ export class HtmlEngine { logger.warn( 'Template path specificed but does not exist...using default templates' ); - // new Error('Template path specified but does not exist'); } } diff --git a/src/app/engines/i18n.engine.ts b/src/app/engines/i18n.engine.ts index 9a13a8c4..029a75c0 100644 --- a/src/app/engines/i18n.engine.ts +++ b/src/app/engines/i18n.engine.ts @@ -3,8 +3,8 @@ import i18next from 'i18next'; import { TRANSLATION_EN_US, TRANSLATION_FR_FR, - TRANSLATION_ZH_CN, - TRANSLATION_PT_BR + TRANSLATION_PT_BR, + TRANSLATION_ZH_CN } from '../../locales'; class I18nEngine { diff --git a/src/app/engines/markdown.engine.ts b/src/app/engines/markdown.engine.ts index 942fa6fb..13ad6c19 100644 --- a/src/app/engines/markdown.engine.ts +++ b/src/app/engines/markdown.engine.ts @@ -1,6 +1,7 @@ import * as fs from 'fs-extra'; -import * as path from 'path'; import * as _ from 'lodash'; +import * as path from 'path'; + import FileEngine from './file.engine'; const marked = require('marked'); diff --git a/src/app/engines/search.engine.ts b/src/app/engines/search.engine.ts index 01c81bd0..438ca054 100644 --- a/src/app/engines/search.engine.ts +++ b/src/app/engines/search.engine.ts @@ -1,9 +1,11 @@ -import * as path from 'path'; import * as Handlebars from 'handlebars'; +import * as path from 'path'; + +import { MAX_SIZE_FILE_CHEERIO_PARSING, MAX_SIZE_FILE_SEARCH_INDEX } from '../../utils/constants'; + import { logger } from '../../utils/logger'; import Configuration from '../configuration'; import FileEngine from './file.engine'; -import { MAX_SIZE_FILE_SEARCH_INDEX, MAX_SIZE_FILE_CHEERIO_PARSING } from '../../utils/constants'; const lunr: any = require('lunr'); const cheerio: any = require('cheerio'); diff --git a/src/app/interfaces/configuration-file.interface.ts b/src/app/interfaces/configuration-file.interface.ts new file mode 100644 index 00000000..d7481afa --- /dev/null +++ b/src/app/interfaces/configuration-file.interface.ts @@ -0,0 +1,46 @@ +export interface ConfigurationFileInterface { + output: string; + extTheme: string; + language: string; + theme: string; + name: string; + assetsFolder: string; + open: boolean; + toggleMenuItems; + templates: string; + navTabConfig; + includes; + includesName: string; + silent: boolean; + serve; + port: number; + watch: boolean; + exportFormat: string; + hideGenerator: boolean; + coverageTest: number; + coverageMinimumPerFile: number; + coverageTestThresholdFail: string; + coverageTestShowOnlyFailed: boolean; + unitTestCoverage: string; + disableSourceCode: boolean; + disableDomTree: boolean; + disableTemplateTab: boolean; + disableStyleTab: boolean; + disableGraph: boolean; + disableCoverage: boolean; + disablePrivate: boolean; + disableProtected: boolean; + disableInternal: boolean; + disableLifeCycleHooks: boolean; + disableRoutesGraph: boolean; + disableSearch: boolean; + minimal: boolean; + customFavicon: string; + customLogo: string; + gaID: string; + gaSite: string; + tsconfig: string; + files; + exclude; + include; +} diff --git a/src/app/interfaces/coverageData.interface.ts b/src/app/interfaces/coverageData.interface.ts new file mode 100644 index 00000000..96e633b2 --- /dev/null +++ b/src/app/interfaces/coverageData.interface.ts @@ -0,0 +1,3 @@ +export interface CoverageData { + files: any; +} diff --git a/src/app/interfaces/jsdoc-tag.interface.ts b/src/app/interfaces/jsdoc-tag.interface.ts index e862a7aa..d03d53e4 100644 --- a/src/app/interfaces/jsdoc-tag.interface.ts +++ b/src/app/interfaces/jsdoc-tag.interface.ts @@ -1,21 +1,21 @@ -export interface jsdocTagNameInterface { +export interface JsdocTagNameInterface { text: string; } -export interface jsdocTypeExpressionInterface { +export interface JsdocTypeExpressionInterface { type: any; } -export interface jsdocParameterNameInterface { +export interface JsdocParameterNameInterface { text: string; } export interface JsdocTagInterface { comment: string; name: string; - tagName: jsdocTagNameInterface; - parameterName: jsdocParameterNameInterface; + tagName: JsdocTagNameInterface; + parameterName: JsdocParameterNameInterface; type: any; defaultValue: any; - typeExpression: jsdocTypeExpressionInterface; + typeExpression: JsdocTypeExpressionInterface; } diff --git a/src/app/interfaces/main-data.interface.ts b/src/app/interfaces/main-data.interface.ts index 7ae667f4..35f11d18 100644 --- a/src/app/interfaces/main-data.interface.ts +++ b/src/app/interfaces/main-data.interface.ts @@ -1,3 +1,5 @@ +import { CoverageData } from './coverageData.interface'; + export interface MainDataInterface { output: string; theme: string; @@ -62,7 +64,7 @@ export interface MainDataInterface { routesLength: number; angularVersion: string; exportFormat: string; - coverageData: Object; + coverageData: CoverageData; customFavicon: string; customLogo: string; packageDependencies: Object[]; diff --git a/src/app/nodes/angular-ngmodule-node.ts b/src/app/nodes/angular-ngmodule-node.ts index f0af72ac..ac1db4c3 100644 --- a/src/app/nodes/angular-ngmodule-node.ts +++ b/src/app/nodes/angular-ngmodule-node.ts @@ -7,4 +7,5 @@ export interface AngularNgModuleNode { bootstrap?; schemas?; id?; + name?; } diff --git a/src/index-cli.ts b/src/index-cli.ts index cb0029ee..aafa75c7 100644 --- a/src/index-cli.ts +++ b/src/index-cli.ts @@ -8,6 +8,7 @@ import Configuration from './app/configuration'; import FileEngine from './app/engines/file.engine'; import I18nEngine from './app/engines/i18n.engine'; +import { ConfigurationFileInterface } from './app/interfaces/configuration-file.interface'; import AngularVersionUtil from './utils/angular-version.util'; import { COMPODOC_DEFAULTS } from './utils/defaults'; import { logger } from './utils/logger'; @@ -180,7 +181,7 @@ Note: Certain tabs will only be shown if applicable to a given dependency`, let configExplorerResult; - let configFile = {}; + let configFile: ConfigurationFileInterface = {}; if (program.config) { let configFilePath = program.config; diff --git a/src/utils/extends-merger.util.ts b/src/utils/extends-merger.util.ts index 7fdd3665..9c11426b 100644 --- a/src/utils/extends-merger.util.ts +++ b/src/utils/extends-merger.util.ts @@ -1,4 +1,5 @@ -import { find, concat, cloneDeep } from 'lodash'; +import { cloneDeep, concat, find } from 'lodash'; + import { cleanLifecycleHooksFromMethods } from '.'; import Configuration from '../app/configuration'; diff --git a/src/utils/imports.util.ts b/src/utils/imports.util.ts index 3a323164..532fb38b 100644 --- a/src/utils/imports.util.ts +++ b/src/utils/imports.util.ts @@ -1,6 +1,6 @@ import * as path from 'path'; -import Ast, { PropertyDeclaration, ts, SyntaxKind } from 'ts-simple-ast'; +import Ast, { ts, PropertyDeclaration, SyntaxKind } from 'ts-simple-ast'; const ast = new Ast(); diff --git a/src/utils/jsdoc-parser.util.ts b/src/utils/jsdoc-parser.util.ts index 687affb1..470ff84f 100644 --- a/src/utils/jsdoc-parser.util.ts +++ b/src/utils/jsdoc-parser.util.ts @@ -1,5 +1,5 @@ -import { ts, SyntaxKind } from 'ts-simple-ast'; import * as _ from 'lodash'; +import { ts, SyntaxKind } from 'ts-simple-ast'; import { JSDocParameterTagExt } from '../app/nodes/jsdoc-parameter-tag.node'; diff --git a/src/utils/router-parser.util.ts b/src/utils/router-parser.util.ts index 796b07b3..2d557793 100644 --- a/src/utils/router-parser.util.ts +++ b/src/utils/router-parser.util.ts @@ -1,11 +1,12 @@ -import * as path from 'path'; import * as Handlebars from 'handlebars'; -import * as _ from 'lodash'; import * as JSON5 from 'json5'; -import Ast, { TypeGuards, SourceFile, ts, SyntaxKind } from 'ts-simple-ast'; +import * as _ from 'lodash'; +import * as path from 'path'; +import Ast, { ts, SourceFile, SyntaxKind, TypeGuards } from 'ts-simple-ast'; import FileEngine from '../app/engines/file.engine'; import { RoutingGraphNode } from '../app/nodes/routing-graph-node'; + import ImportsUtil from './imports.util'; import { logger } from './logger'; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 387cbfc4..e225c808 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,7 +1,7 @@ -import * as path from 'path'; import * as fs from 'fs-extra'; -import { ts } from 'ts-simple-ast'; import * as _ from 'lodash'; +import * as path from 'path'; +import { ts } from 'ts-simple-ast'; import { LinkParser } from './link-parser'; @@ -183,10 +183,10 @@ if (!Array.prototype.includes) { } // 1. Let O be ? ToObject(this value). - var o = Object(this); + let o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")). - var len = o.length >>> 0; + let len = o.length >>> 0; // 3. If len is 0, return false. if (len === 0) { @@ -195,14 +195,14 @@ if (!Array.prototype.includes) { // 4. Let n be ? ToInteger(fromIndex). // (If fromIndex is undefined, this step produces the value 0.) - var n = fromIndex | 0; + let n = fromIndex | 0; // 5. If n ≥ 0, then // a. Let k be n. // 6. Else n < 0, // a. Let k be len + n. // b. If k < 0, let k be 0. - var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); function sameValueZero(x, y) { return ( @@ -310,26 +310,28 @@ export function compilerHost(transpileOptions: any): ts.CompilerHost { return toReturn; } -export function detectIndent(str, count, indent?): string { - let stripIndent = (str: string) => { - const match = str.match(/^[ \t]*(?=\S)/gm); +export function detectIndent(str, count): string { + let stripIndent = (stripedString: string) => { + const match = stripedString.match(/^[ \t]*(?=\S)/gm); if (!match) { - return str; + return stripedString; } // TODO: use spread operator when targeting Node.js 6 const indent = Math.min.apply(Math, match.map(x => x.length)); // eslint-disable-line const re = new RegExp(`^[ \\t]{${indent}}`, 'gm'); - return indent > 0 ? str.replace(re, '') : str; + return indent > 0 ? stripedString.replace(re, '') : stripedString; }; - let repeating = (n, str) => { - str = str === undefined ? ' ' : str; + let repeating = (n, repeatString) => { + repeatString = repeatString === undefined ? ' ' : repeatString; - if (typeof str !== 'string') { - throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``); + if (typeof repeatString !== 'string') { + throw new TypeError( + `Expected \`input\` to be a \`string\`, got \`${typeof repeatString}\`` + ); } if (n < 0) { @@ -340,39 +342,43 @@ export function detectIndent(str, count, indent?): string { do { if (n & 1) { - ret += str; + ret += repeatString; } - str += str; + repeatString += repeatString; } while ((n >>= 1)); return ret; }; - let indentString = (str, count, indent) => { - indent = indent === undefined ? ' ' : indent; - count = count === undefined ? 1 : count; + let indentString = (indentedString, indentCount) => { + let indent = ' '; + indentCount = indentCount === undefined ? 1 : indentCount; - if (typeof str !== 'string') { - throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``); + if (typeof indentedString !== 'string') { + throw new TypeError( + `Expected \`input\` to be a \`string\`, got \`${typeof indentedString}\`` + ); } - if (typeof count !== 'number') { - throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``); + if (typeof indentCount !== 'number') { + throw new TypeError( + `Expected \`count\` to be a \`number\`, got \`${typeof indentCount}\`` + ); } if (typeof indent !== 'string') { throw new TypeError(`Expected \`indent\` to be a \`string\`, got \`${typeof indent}\``); } - if (count === 0) { - return str; + if (indentCount === 0) { + return indentedString; } - indent = count > 1 ? repeating(count, indent) : indent; + indent = indentCount > 1 ? repeating(indentCount, indent) : indent; - return str.replace(/^(?!\s*$)/gm, indent); + return indentedString.replace(/^(?!\s*$)/gm, indent); }; - return indentString(stripIndent(str), count || 0, indent); + return indentString(stripIndent(str), count || 0); }