From 53be9a743e093e80d11b241f75a2114d8bbd07ac Mon Sep 17 00:00:00 2001 From: Oleg Pimenov Date: Sun, 5 Aug 2018 23:12:25 +0300 Subject: [PATCH] feat(build): updated tslint command * clean some tools files --- package.json | 2 +- tools/dgeni/common/decorators.ts | 22 +++-- tools/dgeni/common/dgeni-definitions.ts | 13 +-- tools/dgeni/common/directive-metadata.ts | 10 +- .../common/normalize-method-parameters.ts | 9 +- tools/dgeni/common/property-bindings.ts | 10 +- tools/dgeni/common/sort-members.ts | 2 +- tools/dgeni/processors/categorizer.ts | 22 +++-- tools/dgeni/processors/component-grouper.ts | 19 ++-- tools/dgeni/processors/docs-private-filter.ts | 96 ++++++++++--------- .../processors/filter-duplicate-exports.ts | 67 ++++++------- .../processors/merge-inherited-properties.ts | 57 +++++------ tools/gulp/utils/helpers.ts | 6 +- tools/packages/ngc-compile.ts | 4 +- tools/packages/secondary-entry-points.ts | 4 +- tools/packages/sourcemap-remap.ts | 1 + 16 files changed, 182 insertions(+), 162 deletions(-) diff --git a/package.json b/package.json index 8e0043a5e..8acd67df7 100644 --- a/package.json +++ b/package.json @@ -136,7 +136,7 @@ "build:docs": "gulp docs", "changelog": "ts-node --project ./scripts/tsconfig.deploy.json ./scripts/changelog.ts", "publish": "ts-node --project ./scripts/tsconfig.deploy.json ./scripts/deploy/publish-artifacts.ts", - "linter:lib": "tslint './src/lib'", + "linter:lib": "tslint --config 'tslint.json' --project '.'", "linter:styles": "stylelint --syntax scss \"./**/*.scss\"", "server-dev": "webpack-dev-server --config tools/webpack/webpack.lib.dev.js", "server-dev:button": "npm run server-dev -- --env.component button", diff --git a/tools/dgeni/common/decorators.ts b/tools/dgeni/common/decorators.ts index fbd13a3ef..b914d2203 100644 --- a/tools/dgeni/common/decorators.ts +++ b/tools/dgeni/common/decorators.ts @@ -1,7 +1,9 @@ -import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; -import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; -import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; -import {CategorizedClassDoc, DeprecationDoc, HasDecoratorsDoc} from './dgeni-definitions'; +import { ClassExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; +import { MemberDoc } from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; +import { PropertyMemberDoc } from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; + +import { CategorizedClassDoc, DeprecationDoc, HasDecoratorsDoc } from './dgeni-definitions'; + /** * We want to avoid emitting selectors that are deprecated but don't have a way to mark @@ -13,7 +15,7 @@ const SELECTOR_BLACKLIST = new Set([ '[portalHost]', 'textarea[mat-autosize]', '[overlay-origin]', - '[connected-overlay]', + '[connected-overlay]' ]); export function isMethod(doc: MemberDoc) { @@ -24,6 +26,7 @@ export function isGenericTypeParameter(doc: MemberDoc) { if (doc.containerDoc instanceof ClassExportDoc) { return doc.containerDoc.typeParams && `<${doc.name}>` === doc.containerDoc.typeParams; } + return false; } @@ -35,6 +38,7 @@ export function isProperty(doc: MemberDoc) { (!isMethod(doc) && (doc.isGetAccessor || doc.isSetAccessor))) { return !isGenericTypeParameter(doc); } + return false; } @@ -64,22 +68,22 @@ export function getDirectiveSelectors(classDoc: CategorizedClassDoc) { if (directiveSelectors) { // Filter blacklisted selectors and remove line-breaks in resolved selectors. return directiveSelectors.replace(/[\r\n]/g, '').split(/\s*,\s*/) - .filter(s => s !== '' && !s.includes('md') && !SELECTOR_BLACKLIST.has(s)); + .filter((s) => s !== '' && !s.includes('md') && !SELECTOR_BLACKLIST.has(s)); } } export function hasMemberDecorator(doc: MemberDoc, decoratorName: string) { - return doc.docType == 'member' && hasDecorator(doc, decoratorName); + return doc.docType === 'member' && hasDecorator(doc, decoratorName); } export function hasClassDecorator(doc: ClassExportDoc, decoratorName: string) { - return doc.docType == 'class' && hasDecorator(doc, decoratorName); + return doc.docType === 'class' && hasDecorator(doc, decoratorName); } export function hasDecorator(doc: HasDecoratorsDoc, decoratorName: string) { return !!doc.decorators && doc.decorators.length > 0 && - doc.decorators.some(d => d.name == decoratorName); + doc.decorators.some((d) => d.name === decoratorName); } export function getDeletionTarget(doc: any): string | null { diff --git a/tools/dgeni/common/dgeni-definitions.ts b/tools/dgeni/common/dgeni-definitions.ts index ebae4a095..89ca7b1fb 100644 --- a/tools/dgeni/common/dgeni-definitions.ts +++ b/tools/dgeni/common/dgeni-definitions.ts @@ -1,9 +1,10 @@ -import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc'; -import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; -import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc'; -import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; -import {ParsedDecorator} from 'dgeni-packages/typescript/services/TsParser/getDecorators'; -import {NormalizedMethodMemberDoc} from './normalize-method-parameters'; +import { ApiDoc } from 'dgeni-packages/typescript/api-doc-types/ApiDoc'; +import { ClassExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; +import { ClassLikeExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc'; +import { PropertyMemberDoc } from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; +import { ParsedDecorator } from 'dgeni-packages/typescript/services/TsParser/getDecorators'; + +import { NormalizedMethodMemberDoc } from './normalize-method-parameters'; /** Interface that describes categorized docs that can be deprecated. */ diff --git a/tools/dgeni/common/directive-metadata.ts b/tools/dgeni/common/directive-metadata.ts index 5e65d0601..f47c36532 100644 --- a/tools/dgeni/common/directive-metadata.ts +++ b/tools/dgeni/common/directive-metadata.ts @@ -1,4 +1,3 @@ -import {CategorizedClassDoc} from './dgeni-definitions'; import { ArrayLiteralExpression, CallExpression, @@ -7,6 +6,9 @@ import { StringLiteral, SyntaxKind } from 'typescript'; +import { CategorizedClassDoc } from './dgeni-definitions'; + + /** * Determines the component or directive metadata from the specified Dgeni class doc. The resolved * directive metadata will be stored in a Map. @@ -30,9 +32,9 @@ export function getDirectiveMetadata(classDoc: CategorizedClassDoc): Map decorator.expression) - .filter(decorator => (decorator.expression.kind as any) === SyntaxKind.CallExpression) - .find(decorator => (decorator.expression as any).expression.getText() === 'Component' || + .filter((decorator) => decorator.expression) + .filter((decorator) => (decorator.expression.kind as any) === SyntaxKind.CallExpression) + .find((decorator) => (decorator.expression as any).expression.getText() === 'Component' || (decorator.expression as any).expression.getText() === 'Directive'); if (!directiveDecorator) { diff --git a/tools/dgeni/common/normalize-method-parameters.ts b/tools/dgeni/common/normalize-method-parameters.ts index a4c0df066..617961be2 100644 --- a/tools/dgeni/common/normalize-method-parameters.ts +++ b/tools/dgeni/common/normalize-method-parameters.ts @@ -1,4 +1,4 @@ -import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc'; +import { MethodMemberDoc } from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc'; export class NormalizedMethodMemberDoc extends MethodMemberDoc { @@ -23,7 +23,7 @@ export interface MethodParameterInfo { */ export function normalizeMethodParameters(method: NormalizedMethodMemberDoc) { if (method.parameters) { - method.parameters.forEach(parameter => { + method.parameters.forEach((parameter) => { let [parameterName, parameterType] = parameter.split(':'); // If the parameter is optional, the name here will contain a '?'. We store whether the @@ -41,16 +41,17 @@ export function normalizeMethodParameters(method: NormalizedMethodMemberDoc) { if (!parameterType) { console.warn(`Missing parameter type information (${parameterName}) in ` + `${method.fileInfo.relativePath}:${method.startingLine}`); + return; } - const existingParameterInfo = method.params.find(p => p.name == parameterName); + const existingParameterInfo = method.params.find((p) => p.name === parameterName); if (!existingParameterInfo) { method.params.push({ name: parameterName, type: parameterType.trim(), - isOptional: isOptional + isOptional }); } else { existingParameterInfo.type = parameterType.trim(); diff --git a/tools/dgeni/common/property-bindings.ts b/tools/dgeni/common/property-bindings.ts index 6c18952d1..bd2e85769 100644 --- a/tools/dgeni/common/property-bindings.ts +++ b/tools/dgeni/common/property-bindings.ts @@ -1,7 +1,9 @@ -import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; -import {hasMemberDecorator} from './decorators'; +import { PropertyMemberDoc } from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; +import { hasMemberDecorator } from './decorators'; + +/* tslint:disable:no-non-null-assertion */ /** Interface that describes an Angular property binding. Can be either an input or output. */ export interface PropertyBinding { name: string; @@ -35,7 +37,7 @@ function getBindingPropertyData(doc: PropertyMemberDoc, metadata: Map value.split(':')[0] === doc.name); + const foundValue = metadataValues.find((value) => value.split(':')[0] === doc.name); if (foundValue) { return { @@ -48,7 +50,7 @@ function getBindingPropertyData(doc: PropertyMemberDoc, metadata: Map d.name == decoratorName)!.arguments![0] + alias: doc.decorators!.find((d) => d.name === decoratorName)!.arguments![0] }; } } diff --git a/tools/dgeni/common/sort-members.ts b/tools/dgeni/common/sort-members.ts index 256239b5c..68097ad50 100644 --- a/tools/dgeni/common/sort-members.ts +++ b/tools/dgeni/common/sort-members.ts @@ -1,4 +1,4 @@ -import {CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc} from './dgeni-definitions'; +import { CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc } from './dgeni-definitions'; /** Combined type for a categorized method member document. */ diff --git a/tools/dgeni/processors/categorizer.ts b/tools/dgeni/processors/categorizer.ts index 57e13749a..75bfb23d5 100644 --- a/tools/dgeni/processors/categorizer.ts +++ b/tools/dgeni/processors/categorizer.ts @@ -1,6 +1,6 @@ -import {DocCollection, Processor} from 'dgeni'; -import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc'; -import {getDirectiveMetadata} from '../common/directive-metadata'; +import { DocCollection, Processor } from 'dgeni'; +import { MethodMemberDoc } from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc'; + import { decorateDeprecatedDoc, getDirectiveSelectors, isDirective, isMethod, isNgModule, isProperty, isService @@ -9,11 +9,13 @@ import { CategorizedClassDoc, CategorizedClassLikeDoc, CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc } from '../common/dgeni-definitions'; -import {normalizeMethodParameters} from '../common/normalize-method-parameters'; -import {getInputBindingData, getOutputBindingData} from '../common/property-bindings'; -import {sortCategorizedMembers} from '../common/sort-members'; +import { getDirectiveMetadata } from '../common/directive-metadata'; +import { normalizeMethodParameters } from '../common/normalize-method-parameters'; +import { getInputBindingData, getOutputBindingData } from '../common/property-bindings'; +import { sortCategorizedMembers } from '../common/sort-members'; +/* tslint:disable:no-non-null-assertion */ /** * Processor to add properties to docs objects. * @@ -28,8 +30,8 @@ export class Categorizer implements Processor { $process(docs: DocCollection) { docs - .filter(doc => doc.docType === 'class' || doc.docType === 'interface') - .forEach(doc => this.decorateClassLikeDoc(doc)); + .filter((doc) => doc.docType === 'class' || doc.docType === 'interface') + .forEach((doc) => this.decorateClassLikeDoc(doc)); } /** @@ -52,8 +54,8 @@ export class Categorizer implements Processor { } // Call decorate hooks that can modify the method and property docs. - classLikeDoc.methods.forEach(doc => this.decorateMethodDoc(doc)); - classLikeDoc.properties.forEach(doc => this.decoratePropertyDoc(doc)); + classLikeDoc.methods.forEach((doc) => this.decorateMethodDoc(doc)); + classLikeDoc.properties.forEach((doc) => this.decoratePropertyDoc(doc)); decorateDeprecatedDoc(classLikeDoc); diff --git a/tools/dgeni/processors/component-grouper.ts b/tools/dgeni/processors/component-grouper.ts index e4ac646f4..708ea2051 100644 --- a/tools/dgeni/processors/component-grouper.ts +++ b/tools/dgeni/processors/component-grouper.ts @@ -1,11 +1,12 @@ import * as path from 'path'; -import {DocCollection, Document, Processor} from 'dgeni'; -import {InterfaceExportDoc} from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc'; +import { DocCollection, Document, Processor } from 'dgeni'; +import { InterfaceExportDoc } from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc'; -import {CategorizedClassDoc} from '../common/dgeni-definitions'; +import { CategorizedClassDoc } from '../common/dgeni-definitions'; +/* tslint:disable:no-non-null-assertion */ /** Component group data structure. */ export class ComponentGroup { @@ -66,14 +67,14 @@ export class ComponentGrouper implements Processor { // Map of group name to group instance. const groups = new Map(); - docs.forEach(doc => { + docs.forEach((doc) => { const documentInfo = getDocumentPackageInfo(doc); const packageName = documentInfo.packageName; const packageDisplayName = documentInfo.packageName === 'cdk' ? 'CDK' : 'Mosaic'; const moduleImportPath = `@ptsecurity/${packageName}/${documentInfo.entryPointName}`; - const groupName = packageName + '-' + documentInfo.name; + const groupName = `${packageName}-${documentInfo.name}`; // Get the group for this doc, or, if one does not exist, create it. let group; @@ -96,9 +97,9 @@ export class ComponentGrouper implements Processor { group.services.push(doc); } else if (doc.isNgModule) { group.ngModule = doc; - } else if (doc.docType == 'class') { + } else if (doc.docType === 'class') { group.additionalClasses.push(doc); - } else if (doc.docType == 'interface') { + } else if (doc.docType === 'interface') { group.additionalInterfaces.push(doc); } }); @@ -116,11 +117,11 @@ function getDocumentPackageInfo(doc: Document) { // All of the component documentation is under either `src/lib` or `src/cdk`. // We group the docs up by the directory immediately under that root. const pathSegments = path.relative(basePath, filePath).split(path.sep); - let groupName = pathSegments[1]; + const groupName = pathSegments[1]; return { name: groupName, packageName: pathSegments[0] === 'lib' ? 'mosaic' : pathSegments[0], - entryPointName: pathSegments[1], + entryPointName: pathSegments[1] }; } diff --git a/tools/dgeni/processors/docs-private-filter.ts b/tools/dgeni/processors/docs-private-filter.ts index e677b58d2..c7f99cd7f 100644 --- a/tools/dgeni/processors/docs-private-filter.ts +++ b/tools/dgeni/processors/docs-private-filter.ts @@ -1,64 +1,66 @@ -import {DocCollection, Processor} from 'dgeni'; -import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc'; -import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; -import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; +import { DocCollection, Processor } from 'dgeni'; +import { ApiDoc } from 'dgeni-packages/typescript/api-doc-types/ApiDoc'; +import { ClassExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; +import { MemberDoc } from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; -const INTERNAL_METHODS = [ - // Lifecycle methods - 'ngOnInit', - 'ngOnChanges', - 'ngDoCheck', - 'ngAfterContentInit', - 'ngAfterContentChecked', - 'ngAfterViewInit', - 'ngAfterViewChecked', - 'ngOnDestroy', +const INTERNAL_METHODS: any = [ + // Lifecycle methods + 'ngOnInit', + 'ngOnChanges', + 'ngDoCheck', + 'ngAfterContentInit', + 'ngAfterContentChecked', + 'ngAfterViewInit', + 'ngAfterViewChecked', + 'ngOnDestroy', - // ControlValueAccessor methods - 'writeValue', - 'registerOnChange', - 'registerOnTouched', - 'setDisabledState', + // ControlValueAccessor methods + 'writeValue', + 'registerOnChange', + 'registerOnTouched', + 'setDisabledState', - // Don't ever need to document constructors - 'constructor', + // Don't ever need to document constructors + 'constructor', - // tabIndex exists on all elements, no need to document it - 'tabIndex', + // tabIndex exists on all elements, no need to document it + 'tabIndex' ]; /** * Processor to filter out symbols that should not be shown in the Mosaic docs. */ export class DocsPrivateFilter implements Processor { - name = 'docs-private-filter'; - $runBefore = ['categorizer']; + name = 'docs-private-filter'; + $runBefore = ['categorizer']; - $process(docs: DocCollection) { - return docs.filter(doc => this.isPublicDoc(doc)); - } + $process(docs: DocCollection) { + return docs.filter((doc) => this.isPublicDoc(doc)); + } + + /** Marks the given API doc with a property that describes its public state. */ + private isPublicDoc(doc: ApiDoc) { + if (this.hasDocsPrivateTag(doc) || doc.name.startsWith('_')) { + return false; + } else if (doc instanceof MemberDoc) { + return !this.isInternalMember(doc); + } else if (doc instanceof ClassExportDoc) { + doc.members = doc.members.filter((memberDoc) => this.isPublicDoc(memberDoc)); + } - /** Marks the given API doc with a property that describes its public state. */ - private isPublicDoc(doc: ApiDoc) { - if (this.hasDocsPrivateTag(doc) || doc.name.startsWith('_')) { - return false; - } else if (doc instanceof MemberDoc) { - return !this.isInternalMember(doc); - } else if (doc instanceof ClassExportDoc) { - doc.members = doc.members.filter(memberDoc => this.isPublicDoc(memberDoc)); + return true; } - return true; - } - /** Whether the given method member is listed as an internal member. */ - private isInternalMember(memberDoc: MemberDoc) { - return INTERNAL_METHODS.includes(memberDoc.name); - } + /** Whether the given method member is listed as an internal member. */ + private isInternalMember(memberDoc: MemberDoc) { + return INTERNAL_METHODS.includes(memberDoc.name); + } - /** Whether the given doc has a @docs-private tag set. */ - private hasDocsPrivateTag(doc: any) { - const tags = doc.tags && doc.tags.tags; - return tags ? tags.find((d: any) => d.tagName == 'docs-private') : false; - } + /** Whether the given doc has a @docs-private tag set. */ + private hasDocsPrivateTag(doc: any) { + const tags = doc.tags && doc.tags.tags; + + return tags ? tags.find((d: any) => d.tagName === 'docs-private') : false; + } } diff --git a/tools/dgeni/processors/filter-duplicate-exports.ts b/tools/dgeni/processors/filter-duplicate-exports.ts index fc18558ed..a3870d391 100644 --- a/tools/dgeni/processors/filter-duplicate-exports.ts +++ b/tools/dgeni/processors/filter-duplicate-exports.ts @@ -21,45 +21,46 @@ import { ExportDoc } from 'dgeni-packages/typescript/api-doc-types/ExportDoc'; * re-exported with a different name (for deprecation), or from a different secondary entry-point. */ export class FilterDuplicateExports implements Processor { - name = 'filter-duplicate-exports'; - $runBefore = ['categorizer']; + name = 'filter-duplicate-exports'; + $runBefore = ['categorizer']; - $process(docs: DocCollection) { - const duplicateDocs = this.findDuplicateExports(docs); - return docs.filter(d => !duplicateDocs.has(d)); - } + $process(docs: DocCollection) { + const duplicateDocs = this.findDuplicateExports(docs); - findDuplicateExports(docs: DocCollection) { - const duplicates = new Set(); + return docs.filter((d) => !duplicateDocs.has(d)); + } - docs.forEach(doc => { - if (!(doc instanceof ExportDoc)) { - return; - } + findDuplicateExports(docs: DocCollection) { + const duplicates = new Set(); - // Check for Dgeni documents that refer to the same TypeScript symbol. Those can be - // considered as duplicates of the current document. - const similarDocs = docs.filter(d => d.symbol === doc.symbol); + docs.forEach((doc) => { + if (!(doc instanceof ExportDoc)) { + return; + } - if (similarDocs.length > 1) { - // If there are multiple docs that refer to the same TypeScript symbol, but have a - // different name than the resolved symbol, we can remove those documents, since they - // are just aliasing an already existing export. - similarDocs - .filter(d => d.symbol.name !== d.name) - .forEach(d => duplicates.add(d)); + // Check for Dgeni documents that refer to the same TypeScript symbol. Those can be + // considered as duplicates of the current document. + const similarDocs = docs.filter((d) => d.symbol === doc.symbol); - const docsWithSameName = similarDocs - .filter(d => d.symbol.name === d.name); + if (similarDocs.length > 1) { + // If there are multiple docs that refer to the same TypeScript symbol, but have a + // different name than the resolved symbol, we can remove those documents, since they + // are just aliasing an already existing export. + similarDocs + .filter((d) => d.symbol.name !== d.name) + .forEach((d) => duplicates.add(d)); - // If there are multiple docs that refer to the same TypeScript symbol and have - // the same name, we need to remove all of those duplicates except one. - if (docsWithSameName.length > 1) { - docsWithSameName.slice(1).forEach(d => duplicates.add(d)); - } - } - }); + const docsWithSameName = similarDocs + .filter((d) => d.symbol.name === d.name); - return duplicates; - } + // If there are multiple docs that refer to the same TypeScript symbol and have + // the same name, we need to remove all of those duplicates except one. + if (docsWithSameName.length > 1) { + docsWithSameName.slice(1).forEach((d) => duplicates.add(d)); + } + } + }); + + return duplicates; + } } diff --git a/tools/dgeni/processors/merge-inherited-properties.ts b/tools/dgeni/processors/merge-inherited-properties.ts index 4d7ae1b6e..163830003 100644 --- a/tools/dgeni/processors/merge-inherited-properties.ts +++ b/tools/dgeni/processors/merge-inherited-properties.ts @@ -1,6 +1,6 @@ -import {DocCollection, Processor} from 'dgeni'; -import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; -import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; +import { DocCollection, Processor } from 'dgeni'; +import { ClassExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; +import { MemberDoc } from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; /** @@ -8,35 +8,36 @@ import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; * to properly show public properties from TypeScript mixin interfaces in the API. */ export class MergeInheritedProperties implements Processor { - name = 'merge-inherited-properties'; - $runBefore = ['categorizer']; + name = 'merge-inherited-properties'; + $runBefore = ['categorizer']; - $process(docs: DocCollection) { - return docs - .filter(doc => doc.docType === 'class') - .forEach(doc => this.addInheritedProperties(doc)); - } + $process(docs: DocCollection) { + return docs + .filter((doc) => doc.docType === 'class') + .forEach((doc) => this.addInheritedProperties(doc)); + } - private addInheritedProperties(doc: ClassExportDoc) { - doc.implementsClauses.filter(clause => clause.doc).forEach(clause => { - clause.doc!.members.forEach(member => this.addMemberDocIfNotPresent(doc, member)); - }); + /* tslint:disable:no-non-null-assertion */ + private addInheritedProperties(doc: ClassExportDoc) { + doc.implementsClauses.filter((clause) => clause.doc).forEach((clause) => { + clause.doc!.members.forEach((member) => this.addMemberDocIfNotPresent(doc, member)); + }); - doc.extendsClauses.filter(clause => clause.doc).forEach(clause => { - clause.doc!.members.forEach(member => this.addMemberDocIfNotPresent(doc, member)); - }); - } + doc.extendsClauses.filter((clause) => clause.doc).forEach((clause) => { + clause.doc!.members.forEach((member) => this.addMemberDocIfNotPresent(doc, member)); + }); + } - private addMemberDocIfNotPresent(destination: ClassExportDoc, memberDoc: MemberDoc) { - if (!destination.members.find(member => member.name === memberDoc.name)) { - // To be able to differentiate between member docs from the heritage clause and the - // member doc for the destination class, we clone the member doc. It's important to keep - // the prototype and reference because later, Dgeni identifies members and properties - // by using an instance comparison. - const newMemberDoc = Object.assign(Object.create(memberDoc), memberDoc); - newMemberDoc.containerDoc = destination; + private addMemberDocIfNotPresent(destination: ClassExportDoc, memberDoc: MemberDoc) { + if (!destination.members.find((member) => member.name === memberDoc.name)) { + // To be able to differentiate between member docs from the heritage clause and the + // member doc for the destination class, we clone the member doc. It's important to keep + // the prototype and reference because later, Dgeni identifies members and properties + // by using an instance comparison. + const newMemberDoc = Object.assign(Object.create(memberDoc), memberDoc); + newMemberDoc.containerDoc = destination; - destination.members.push(newMemberDoc); + destination.members.push(newMemberDoc); + } } - } } diff --git a/tools/gulp/utils/helpers.ts b/tools/gulp/utils/helpers.ts index 32d9b20ad..e0147d81d 100644 --- a/tools/gulp/utils/helpers.ts +++ b/tools/gulp/utils/helpers.ts @@ -13,7 +13,7 @@ export function cleanTask(glob: string) { export function execTask(binPath: string, args: string[], options: IExecTaskOptions = {}) { return (done: (err?: string) => void) => { - const env = Object.assign({}, process.env, options.env); + const env = {...process.env, ...options.env}; const childProcess = child_process.spawn(binPath, args, {env}); const stderrData: string[] = []; @@ -40,12 +40,12 @@ export function execTask(binPath: string, args: string[], options: IExecTaskOpti export function execNodeTask(packageName: string, executable: string | string[], args?: string[], options: IExecTaskOptions = {}) { if (!args) { - args = executable; + args = executable; executable = ''; } return (done: (err: any) => void) => { - resolveBin(packageName, { executable: executable }, (err: any, binPath: string) => { + resolveBin(packageName, { executable }, (err: any, binPath: string) => { if (err) { done(err); } else { diff --git a/tools/packages/ngc-compile.ts b/tools/packages/ngc-compile.ts index f8f0033c9..2597c85e6 100644 --- a/tools/packages/ngc-compile.ts +++ b/tools/packages/ngc-compile.ts @@ -1,7 +1,7 @@ import * as chalk from 'chalk'; -import {spawn} from 'child_process'; +import { spawn } from 'child_process'; -import {resolve as resolvePath} from 'path'; +import {resolve as resolvePath } from 'path'; /* tslint:disable:no-console */ diff --git a/tools/packages/secondary-entry-points.ts b/tools/packages/secondary-entry-points.ts index 44f8e40b4..d8d401647 100644 --- a/tools/packages/secondary-entry-points.ts +++ b/tools/packages/secondary-entry-points.ts @@ -56,7 +56,7 @@ export function getSecondaryEntryPointsForPackage(pkg: BuildPackage) { return [...order, ...getBuildOrder(node)]; }, []); - return partitionNodesByDepth(buildOrder).map(level => level.map(node => node.name)); + return partitionNodesByDepth(buildOrder).map((level) => level.map((node) => node.name)); } /** Gets the build order for node with DFS. As a side-effect, sets the depth on visited nodes. */ @@ -66,12 +66,14 @@ function getBuildOrder(node: IBuildNode): IBuildNode[] { } let buildOrder: IBuildNode[] = []; + for (const dep of node.deps) { buildOrder = [...buildOrder, ...getBuildOrder(dep)]; node.depth = node.deps.reduce((maxDepth, d) => Math.max(d.depth + 1, maxDepth), -1); } node.visited = true; + return [...buildOrder, node]; } diff --git a/tools/packages/sourcemap-remap.ts b/tools/packages/sourcemap-remap.ts index 378736a52..91a6d8b3d 100644 --- a/tools/packages/sourcemap-remap.ts +++ b/tools/packages/sourcemap-remap.ts @@ -1,3 +1,4 @@ +/* tslint:disable:no-var-requires */ // There are no type definitions available for these imports. const sorcery = require('sorcery');