Skip to content

Commit 8f65a6a

Browse files
committed
Reapply Prettier following the steps in this comment:
microsoft#1796 (comment) # Conflicts: # apps/api-extractor/src/analyzer/AstSymbolTable.ts # apps/api-extractor/src/analyzer/ExportAnalyzer.ts # apps/api-extractor/src/collector/Collector.ts # apps/api-extractor/src/generators/ApiModelGenerator.ts
2 parents 36250be + a55cd93 commit 8f65a6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1668
-1050
lines changed

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This is a workaround for https://github.com/eslint/eslint/issues/3458
2-
require("@rushstack/eslint-config/patch-eslint6");
2+
require('@rushstack/eslint-config/patch-eslint6');
33

44
module.exports = {
5-
extends: [ "@rushstack/eslint-config" ],
6-
parserOptions: { tsconfigRootDir: __dirname },
5+
extends: ['@rushstack/eslint-config'],
6+
parserOptions: { tsconfigRootDir: __dirname }
77
};

config/api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
"dtsRollup": {
1717
"enabled": true,
18-
"untrimmedFilePath": "<projectFolder>/dist/rollup.d.ts",
18+
"untrimmedFilePath": "<projectFolder>/dist/rollup.d.ts"
1919
}
2020
}

config/jest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"isEnabled": true
3-
}
3+
}

src/aedoc/PackageDocComment.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ export class PackageDocComment {
99
/**
1010
* For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.
1111
*/
12-
public static tryFindInSourceFile(sourceFile: ts.SourceFile,
13-
collector: Collector): ts.TextRange | undefined {
14-
12+
public static tryFindInSourceFile(
13+
sourceFile: ts.SourceFile,
14+
collector: Collector
15+
): ts.TextRange | undefined {
1516
// The @packageDocumentation comment is special because it is not attached to an AST
1617
// definition. Instead, it is part of the "trivia" tokens that the compiler treats
1718
// as irrelevant white space.
@@ -47,8 +48,8 @@ export class PackageDocComment {
4748
// wrong place? This sanity check helps people to figure out why there comment isn't working.
4849
for (const statement of sourceFile.statements) {
4950
const ranges: ts.CommentRange[] = [];
50-
ranges.push(...ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []);
51-
ranges.push(...ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []);
51+
ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));
52+
ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));
5253

5354
for (const commentRange of ranges) {
5455
const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);
@@ -57,7 +58,8 @@ export class PackageDocComment {
5758
collector.messageRouter.addAnalyzerIssueForPosition(
5859
ExtractorMessageId.MisplacedPackageTag,
5960
'The @packageDocumentation comment must appear at the top of entry point *.d.ts file',
60-
sourceFile, commentRange.pos
61+
sourceFile,
62+
commentRange.pos
6163
);
6264
break;
6365
}
@@ -67,5 +69,4 @@ export class PackageDocComment {
6769

6870
return packageCommentRange;
6971
}
70-
7172
}

src/analyzer/AstDeclaration.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,21 @@ export class AstDeclaration {
238238
switch (kind) {
239239
case ts.SyntaxKind.CallSignature:
240240
case ts.SyntaxKind.ClassDeclaration:
241-
case ts.SyntaxKind.ConstructSignature: // Example: "new(x: number): IMyClass"
242-
case ts.SyntaxKind.Constructor: // Example: "constructor(x: number)"
241+
case ts.SyntaxKind.ConstructSignature: // Example: "new(x: number): IMyClass"
242+
case ts.SyntaxKind.Constructor: // Example: "constructor(x: number)"
243243
case ts.SyntaxKind.EnumDeclaration:
244244
case ts.SyntaxKind.EnumMember:
245-
case ts.SyntaxKind.FunctionDeclaration: // Example: "(x: number): number"
245+
case ts.SyntaxKind.FunctionDeclaration: // Example: "(x: number): number"
246246
case ts.SyntaxKind.GetAccessor:
247247
case ts.SyntaxKind.SetAccessor:
248-
case ts.SyntaxKind.IndexSignature: // Example: "[key: string]: string"
248+
case ts.SyntaxKind.IndexSignature: // Example: "[key: string]: string"
249249
case ts.SyntaxKind.InterfaceDeclaration:
250250
case ts.SyntaxKind.MethodDeclaration:
251251
case ts.SyntaxKind.MethodSignature:
252-
case ts.SyntaxKind.ModuleDeclaration: // Used for both "module" and "namespace" declarations
252+
case ts.SyntaxKind.ModuleDeclaration: // Used for both "module" and "namespace" declarations
253253
case ts.SyntaxKind.PropertyDeclaration:
254254
case ts.SyntaxKind.PropertySignature:
255-
case ts.SyntaxKind.TypeAliasDeclaration: // Example: "type Shape = Circle | Square"
255+
case ts.SyntaxKind.TypeAliasDeclaration: // Example: "type Shape = Circle | Square"
256256
case ts.SyntaxKind.VariableDeclaration:
257257
return true;
258258

@@ -268,5 +268,4 @@ export class AstDeclaration {
268268

269269
return false;
270270
}
271-
272271
}

src/analyzer/AstEntity.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ export abstract class AstEntity {
4343
* - `AstImport`
4444
* - `AstImportAsModule`
4545
*/
46-
export abstract class AstSyntheticEntity extends AstEntity {
47-
}
46+
export abstract class AstSyntheticEntity extends AstEntity {}

src/analyzer/AstImport.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export class AstImport extends AstSyntheticEntity {
109109
}
110110

111111
/** {@inheritdoc} */
112-
public get localName(): string { // abstract
112+
public get localName(): string {
113+
// abstract
113114
return this.exportName;
114115
}
115116

src/analyzer/AstImportAsModule.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class AstImportAsModule extends AstSyntheticEntity {
4747
}
4848

4949
/** {@inheritdoc} */
50-
public get localName(): string { // abstract
50+
public get localName(): string {
51+
// abstract
5152
return this.exportName;
5253
}
53-
}
54+
}

src/analyzer/AstReferenceResolver.ts

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ export class AstReferenceResolver {
5353

5454
public resolve(declarationReference: tsdoc.DocDeclarationReference): AstDeclaration | ResolverFailure {
5555
// Is it referring to the working package?
56-
if (declarationReference.packageName !== undefined
57-
&& declarationReference.packageName !== this._workingPackage.name) {
56+
if (
57+
declarationReference.packageName !== undefined &&
58+
declarationReference.packageName !== this._workingPackage.name
59+
) {
5860
return new ResolverFailure('External package references are not supported');
5961
}
6062

@@ -64,7 +66,8 @@ export class AstReferenceResolver {
6466
}
6567

6668
const astModule: AstModule = this._astSymbolTable.fetchAstModuleFromWorkingPackage(
67-
this._workingPackage.entryPointSourceFile);
69+
this._workingPackage.entryPointSourceFile
70+
);
6871

6972
if (declarationReference.memberReferences.length === 0) {
7073
return new ResolverFailure('Package references are not supported');
@@ -78,18 +81,25 @@ export class AstReferenceResolver {
7881
}
7982

8083
const rootAstEntity: AstEntity | undefined = this._astSymbolTable.tryGetExportOfAstModule(
81-
exportName, astModule);
84+
exportName,
85+
astModule
86+
);
8287

8388
if (rootAstEntity === undefined) {
84-
return new ResolverFailure(`The package "${this._workingPackage.name}" does not have an export "${exportName}"`);
89+
return new ResolverFailure(
90+
`The package "${this._workingPackage.name}" does not have an export "${exportName}"`
91+
);
8592
}
8693

8794
if (!(rootAstEntity instanceof AstSymbol)) {
8895
return new ResolverFailure('This type of declaration is not supported yet by the resolver');
8996
}
9097

91-
let currentDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(rootAstEntity.astDeclarations,
92-
rootMemberReference, rootAstEntity.localName);
98+
let currentDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(
99+
rootAstEntity.astDeclarations,
100+
rootMemberReference,
101+
rootAstEntity.localName
102+
);
93103

94104
if (currentDeclaration instanceof ResolverFailure) {
95105
return currentDeclaration;
@@ -103,13 +113,18 @@ export class AstReferenceResolver {
103113
return memberName;
104114
}
105115

106-
const matchingChildren: ReadonlyArray<AstDeclaration> = currentDeclaration.findChildrenWithName(memberName);
116+
const matchingChildren: ReadonlyArray<AstDeclaration> = currentDeclaration.findChildrenWithName(
117+
memberName
118+
);
107119
if (matchingChildren.length === 0) {
108120
return new ResolverFailure(`No member was found with name "${memberName}"`);
109121
}
110122

111-
const selectedDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(matchingChildren,
112-
memberReference, memberName);
123+
const selectedDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(
124+
matchingChildren,
125+
memberReference,
126+
memberName
127+
);
113128

114129
if (selectedDeclaration instanceof ResolverFailure) {
115130
return selectedDeclaration;
@@ -131,9 +146,11 @@ export class AstReferenceResolver {
131146
return memberReference.memberIdentifier.identifier;
132147
}
133148

134-
private _selectDeclaration(astDeclarations: ReadonlyArray<AstDeclaration>,
135-
memberReference: tsdoc.DocMemberReference, astSymbolName: string): AstDeclaration | ResolverFailure {
136-
149+
private _selectDeclaration(
150+
astDeclarations: ReadonlyArray<AstDeclaration>,
151+
memberReference: tsdoc.DocMemberReference,
152+
astSymbolName: string
153+
): AstDeclaration | ResolverFailure {
137154
const memberSelector: tsdoc.DocMemberSelector | undefined = memberReference.selector;
138155

139156
if (memberSelector === undefined) {
@@ -142,13 +159,17 @@ export class AstReferenceResolver {
142159
} else {
143160
// If we found multiple matches, but the extra ones are all ancillary declarations,
144161
// then return the main declaration.
145-
const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(astDeclarations);
162+
const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(
163+
astDeclarations
164+
);
146165
if (nonAncillaryMatch) {
147166
return nonAncillaryMatch;
148167
}
149168

150-
return new ResolverFailure(`The reference is ambiguous because "${astSymbolName}"`
151-
+ ` has more than one declaration; you need to add a TSDoc member reference selector`);
169+
return new ResolverFailure(
170+
`The reference is ambiguous because "${astSymbolName}"` +
171+
` has more than one declaration; you need to add a TSDoc member reference selector`
172+
);
152173
}
153174
}
154175

@@ -162,9 +183,11 @@ export class AstReferenceResolver {
162183
return new ResolverFailure(`The selector "${memberSelector.selector}" is not a supported selector type`);
163184
}
164185

165-
private _selectUsingSystemSelector(astDeclarations: ReadonlyArray<AstDeclaration>,
166-
memberSelector: tsdoc.DocMemberSelector, astSymbolName: string): AstDeclaration | ResolverFailure {
167-
186+
private _selectUsingSystemSelector(
187+
astDeclarations: ReadonlyArray<AstDeclaration>,
188+
memberSelector: tsdoc.DocMemberSelector,
189+
astSymbolName: string
190+
): AstDeclaration | ResolverFailure {
168191
const selectorName: string = memberSelector.selector;
169192

170193
let selectorSyntaxKind: ts.SyntaxKind;
@@ -195,10 +218,14 @@ export class AstReferenceResolver {
195218
return new ResolverFailure(`Unsupported system selector "${selectorName}"`);
196219
}
197220

198-
const matches: AstDeclaration[] = astDeclarations.filter(x => x.declaration.kind === selectorSyntaxKind);
221+
const matches: AstDeclaration[] = astDeclarations.filter(
222+
(x) => x.declaration.kind === selectorSyntaxKind
223+
);
199224
if (matches.length === 0) {
200-
return new ResolverFailure(`A declaration for "${astSymbolName}" was not found that matches the`
201-
+ ` TSDoc selector "${selectorName}"`);
225+
return new ResolverFailure(
226+
`A declaration for "${astSymbolName}" was not found that matches the` +
227+
` TSDoc selector "${selectorName}"`
228+
);
202229
}
203230
if (matches.length > 1) {
204231
// If we found multiple matches, but the extra ones are all ancillary declarations,
@@ -208,15 +235,18 @@ export class AstReferenceResolver {
208235
return nonAncillaryMatch;
209236
}
210237

211-
return new ResolverFailure(`More than one declaration "${astSymbolName}" matches the`
212-
+ ` TSDoc selector "${selectorName}"`);
238+
return new ResolverFailure(
239+
`More than one declaration "${astSymbolName}" matches the TSDoc selector "${selectorName}"`
240+
);
213241
}
214242
return matches[0];
215243
}
216244

217-
private _selectUsingIndexSelector(astDeclarations: ReadonlyArray<AstDeclaration>,
218-
memberSelector: tsdoc.DocMemberSelector, astSymbolName: string): AstDeclaration | ResolverFailure {
219-
245+
private _selectUsingIndexSelector(
246+
astDeclarations: ReadonlyArray<AstDeclaration>,
247+
memberSelector: tsdoc.DocMemberSelector,
248+
astSymbolName: string
249+
): AstDeclaration | ResolverFailure {
220250
const selectorOverloadIndex: number = parseInt(memberSelector.selector);
221251

222252
const matches: AstDeclaration[] = [];
@@ -228,8 +258,10 @@ export class AstReferenceResolver {
228258
}
229259

230260
if (matches.length === 0) {
231-
return new ResolverFailure(`An overload for "${astSymbolName}" was not found that matches the`
232-
+ ` TSDoc selector ":${selectorOverloadIndex}"`);
261+
return new ResolverFailure(
262+
`An overload for "${astSymbolName}" was not found that matches the` +
263+
` TSDoc selector ":${selectorOverloadIndex}"`
264+
);
233265
}
234266
if (matches.length > 1) {
235267
// If we found multiple matches, but the extra ones are all ancillary declarations,
@@ -239,8 +271,10 @@ export class AstReferenceResolver {
239271
return nonAncillaryMatch;
240272
}
241273

242-
return new ResolverFailure(`More than one declaration for "${astSymbolName}" matches the`
243-
+ ` TSDoc selector ":${selectorOverloadIndex}"`);
274+
return new ResolverFailure(
275+
`More than one declaration for "${astSymbolName}" matches the` +
276+
` TSDoc selector ":${selectorOverloadIndex}"`
277+
);
244278
}
245279
return matches[0];
246280
}
@@ -249,7 +283,9 @@ export class AstReferenceResolver {
249283
* This resolves an ambiguous match in the case where the extra matches are all ancillary declarations,
250284
* except for one match that is the main declaration.
251285
*/
252-
private _tryDisambiguateAncillaryMatches(matches: ReadonlyArray<AstDeclaration>): AstDeclaration | undefined {
286+
private _tryDisambiguateAncillaryMatches(
287+
matches: ReadonlyArray<AstDeclaration>
288+
): AstDeclaration | undefined {
253289
let result: AstDeclaration | undefined = undefined;
254290

255291
for (const match of matches) {

0 commit comments

Comments
 (0)