X Tutup
Skip to content

Commit 81cf724

Browse files
committed
Fix ESLint issues for api-extractor
1 parent 9f5dbdd commit 81cf724

17 files changed

+42
-40
lines changed

apps/api-extractor/.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
2+
require("@rushstack/eslint-config/patch-eslint6");
3+
4+
module.exports = {
5+
extends: [ "@rushstack/eslint-config" ],
6+
parserOptions: { tsconfigRootDir: __dirname },
7+
};

apps/api-extractor/src/analyzer/ExportAnalyzer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export class ExportAnalyzer {
333333
if (referringModuleIsExternal) {
334334
current = TypeScriptHelpers.followAliases(symbol, this._typeChecker);
335335
} else {
336-
while (true) { // tslint:disable-line:no-constant-condition
336+
for (; ;) {
337337
// Is this symbol an import/export that we need to follow to find the real declaration?
338338
for (const declaration of current.declarations || []) {
339339

@@ -348,7 +348,7 @@ export class ExportAnalyzer {
348348
}
349349
}
350350

351-
if (!(current.flags & ts.SymbolFlags.Alias)) { // tslint:disable-line:no-bitwise
351+
if (!(current.flags & ts.SymbolFlags.Alias)) { // eslint-disable-line no-bitwise
352352
break;
353353
}
354354

apps/api-extractor/src/analyzer/PackageMetadataManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
FileSystem,
99
JsonFile,
1010
NewlineKind,
11-
INodePackageJson
11+
INodePackageJson,
12+
JsonObject
1213
} from '@microsoft/node-core-library';
1314
import { Extractor } from '../api/Extractor';
1415
import { MessageRouter } from '../collector/MessageRouter';
@@ -127,7 +128,7 @@ export class PackageMetadataManager {
127128
* Writes the TSDoc metadata file to the specified output file.
128129
*/
129130
public static writeTsdocMetadataFile(tsdocMetadataPath: string): void {
130-
const fileObject: Object = {
131+
const fileObject: JsonObject = {
131132
tsdocVersion: '0.12',
132133
toolPackages: [
133134
{

apps/api-extractor/src/analyzer/Span.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ export class SpanModification {
3333
*/
3434
public sortKey: string | undefined;
3535

36-
private readonly span: Span;
36+
private readonly _span: Span;
3737
private _prefix: string | undefined;
3838
private _suffix: string | undefined;
3939

4040
public constructor(span: Span) {
41-
this.span = span;
41+
this._span = span;
4242
this.reset();
4343
}
4444

4545
/**
4646
* Allows the Span.prefix text to be changed.
4747
*/
4848
public get prefix(): string {
49-
return this._prefix !== undefined ? this._prefix : this.span.prefix;
49+
return this._prefix !== undefined ? this._prefix : this._span.prefix;
5050
}
5151

5252
public set prefix(value: string) {
@@ -57,7 +57,7 @@ export class SpanModification {
5757
* Allows the Span.suffix text to be changed.
5858
*/
5959
public get suffix(): string {
60-
return this._suffix !== undefined ? this._suffix : this.span.suffix;
60+
return this._suffix !== undefined ? this._suffix : this._span.suffix;
6161
}
6262

6363
public set suffix(value: string) {

apps/api-extractor/src/analyzer/TypeScriptHelpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class TypeScriptHelpers {
2121
*/
2222
public static followAliases(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {
2323
let current: ts.Symbol = symbol;
24-
while (true) { // tslint:disable-line:no-constant-condition
24+
for (;;) {
2525
if (!(current.flags & ts.SymbolFlags.Alias)) {
2626
break;
2727
}
@@ -84,7 +84,7 @@ export class TypeScriptHelpers {
8484
// is acting as a module or not).
8585
const sourceFile: ts.SourceFile = firstDeclaration.getSourceFile();
8686

87-
if (!!typeChecker.getSymbolAtLocation(sourceFile)) {
87+
if (typeChecker.getSymbolAtLocation(sourceFile)) {
8888
return false;
8989
}
9090
}
@@ -199,7 +199,7 @@ export class TypeScriptHelpers {
199199
let current: ts.Node | undefined = node;
200200
let highest: T | undefined = undefined;
201201

202-
while (true) { // tslint:disable-line:no-constant-condition
202+
for (;;) {
203203
current = TypeScriptHelpers.findFirstParent<T>(current, kindToMatch);
204204
if (!current) {
205205
break;

apps/api-extractor/src/analyzer/TypeScriptInternals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
// tslint:disable:no-any
4+
/* eslint-disable @typescript-eslint/no-explicit-any */
55

66
import * as ts from 'typescript';
77

apps/api-extractor/src/analyzer/test/PackageMetadataManager.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import { PackageMetadataManager } from '../PackageMetadataManager';
44
import { FileSystem, PackageJsonLookup, INodePackageJson } from '@microsoft/node-core-library';
55

6-
/* tslint:disable:typedef */
6+
/* eslint-disable @typescript-eslint/typedef */
77

88
describe('PackageMetadataManager', () => {
99
describe('.writeTsdocMetadataFile()', () => {
@@ -115,7 +115,7 @@ describe('PackageMetadataManager', () => {
115115
});
116116
});
117117

118-
/* tslint:enable:typedef */
118+
/* eslint-enable @typescript-eslint/typedef */
119119

120120
const packageJsonLookup: PackageJsonLookup = new PackageJsonLookup();
121121

apps/api-extractor/src/cli/ApiExtractorCommandLine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { InitAction } from './InitAction';
1313
export class ApiExtractorCommandLine extends CommandLineParser {
1414
private _debugParameter: CommandLineFlagParameter;
1515

16-
constructor() {
16+
public constructor() {
1717
super({
1818
toolFilename: 'api-extractor',
1919
toolDescription: 'API Extractor helps you build better TypeScript libraries. It analyzes the main entry'

apps/api-extractor/src/cli/InitAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ExtractorConfig } from '../api/ExtractorConfig';
1111

1212
export class InitAction extends CommandLineAction {
1313

14-
constructor(parser: ApiExtractorCommandLine) {
14+
public constructor(parser: ApiExtractorCommandLine) {
1515
super({
1616
actionName: 'init',
1717
summary: `Create an ${ExtractorConfig.FILENAME} config file`,

apps/api-extractor/src/cli/RunAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class RunAction extends CommandLineAction {
2929
private _diagnosticsParameter: CommandLineFlagParameter;
3030
private _typescriptCompilerFolder: CommandLineStringParameter;
3131

32-
constructor(parser: ApiExtractorCommandLine) {
32+
public constructor(parser: ApiExtractorCommandLine) {
3333
super({
3434
actionName: 'run',
3535
summary: 'Invoke API Extractor on a project',

0 commit comments

Comments
 (0)
X Tutup