Skip to content

Commit

Permalink
Merge pull request #1593 from microsoft/octogonz/eslint-migration
Browse files Browse the repository at this point in the history
Migrate all projects to use ESLint+TypeScript instead of TSLint
  • Loading branch information
octogonz authored Oct 22, 2019
2 parents 4845cef + ef74f9a commit 5627415
Show file tree
Hide file tree
Showing 410 changed files with 2,665 additions and 2,090 deletions.
7 changes: 7 additions & 0 deletions apps/api-documenter/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require("@rushstack/eslint-config/patch-eslint6");

module.exports = {
extends: [ "@rushstack/eslint-config" ],
parserOptions: { tsconfigRootDir: __dirname },
};
1 change: 1 addition & 0 deletions apps/api-documenter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"devDependencies": {
"@microsoft/rush-stack-compiler-3.4": "0.3.0",
"@microsoft/node-library-build": "6.3.0",
"@rushstack/eslint-config": "0.4.0",
"@types/jest": "23.3.11",
"@types/js-yaml": "3.12.1",
"@types/node": "8.10.54",
Expand Down
2 changes: 1 addition & 1 deletion apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { YamlAction } from './YamlAction';
import { GenerateAction } from './GenerateAction';

export class ApiDocumenterCommandLine extends CommandLineParser {
constructor() {
public constructor() {
super({
toolFilename: 'api-documenter',
toolDescription: 'Reads *.api.json files produced by api-extractor, '
Expand Down
2 changes: 1 addition & 1 deletion apps/api-documenter/src/cli/GenerateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FileSystem } from '@microsoft/node-core-library';
import { MarkdownDocumenter } from '../documenters/MarkdownDocumenter';

export class GenerateAction extends BaseAction {
constructor(parser: ApiDocumenterCommandLine) {
public constructor(parser: ApiDocumenterCommandLine) {
super({
actionName: 'generate',
summary: 'EXPERIMENTAL',
Expand Down
2 changes: 1 addition & 1 deletion apps/api-documenter/src/cli/MarkdownAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MarkdownDocumenter } from '../documenters/MarkdownDocumenter';
import { ApiModel } from '@microsoft/api-extractor-model';

export class MarkdownAction extends BaseAction {
constructor(parser: ApiDocumenterCommandLine) {
public constructor(parser: ApiDocumenterCommandLine) {
super({
actionName: 'markdown',
summary: 'Generate documentation as Markdown files (*.md)',
Expand Down
2 changes: 1 addition & 1 deletion apps/api-documenter/src/cli/YamlAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ApiModel } from '@microsoft/api-extractor-model';
export class YamlAction extends BaseAction {
private _officeParameter: CommandLineFlagParameter;

constructor(parser: ApiDocumenterCommandLine) {
public constructor(parser: ApiDocumenterCommandLine) {
super({
actionName: 'yaml',
summary: 'Generate documentation as universal reference YAML files (*.yml)',
Expand Down
10 changes: 5 additions & 5 deletions apps/api-documenter/src/documenters/DocumenterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export class DocumenterConfig {
*/
public static readonly FILENAME: string = 'api-documenter.json';

private constructor(filePath: string, configFile: IConfigFile) {
this.configFilePath = filePath;
this.configFile = configFile;
}

/**
* Load and validate an api-documenter.json file.
*/
Expand All @@ -33,9 +38,4 @@ export class DocumenterConfig {

return new DocumenterConfig(path.resolve(configFilePath), configFile);
}

private constructor(filePath: string, configFile: IConfigFile) {
this.configFilePath = filePath;
this.configFile = configFile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class OfficeYamlDocumenter extends YamlDocumenter {
private _apiSetUrlDefault: string = '/office/dev/add-ins/reference/javascript-api-for-office';

// Hash set of API Set URLs based on product.
private _apiSetUrls: Object = {
private _apiSetUrls: Record<string, string> = {
'Excel': '/office/dev/add-ins/reference/requirement-sets/excel-api-requirement-sets',
'OneNote': '/office/dev/add-ins/reference/requirement-sets/onenote-api-requirement-sets',
'Visio': '/office/dev/add-ins/reference/overview/visio-javascript-reference-overview',
Expand Down
2 changes: 0 additions & 2 deletions apps/api-documenter/src/documenters/YamlDocumenter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// tslint:disable:member-ordering

import * as path from 'path';

import yaml = require('js-yaml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class MarkdownDocumenterAccessor {
private _implementation: IMarkdownDocumenterAccessorImplementation;

/** @internal */
constructor (implementation: IMarkdownDocumenterAccessorImplementation) {
public constructor (implementation: IMarkdownDocumenterAccessorImplementation) {
this._implementation = implementation;
}

Expand Down
14 changes: 7 additions & 7 deletions apps/api-documenter/src/plugin/MarkdownDocumenterFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ import { MarkdownDocumenterAccessor } from './MarkdownDocumenterAccessor';
* @public
*/
export class MarkdownDocumenterFeatureContext {
/** @internal */
public constructor(options: MarkdownDocumenterFeatureContext) {
this.apiModel = options.apiModel;
this.outputFolder = options.outputFolder;
this.documenter = options.documenter;
}

/**
* Provides access to the `ApiModel` for the documentation being generated.
*/
Expand All @@ -33,6 +26,13 @@ export class MarkdownDocumenterFeatureContext {
* Exposes functionality of the documenter.
*/
public readonly documenter: MarkdownDocumenterAccessor;

/** @internal */
public constructor(options: MarkdownDocumenterFeatureContext) {
this.apiModel = options.apiModel;
this.outputFolder = options.outputFolder;
this.documenter = options.documenter;
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions apps/api-documenter/src/plugin/PluginFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* @public
*/
export class PluginFeatureInitialization {
/** @internal */
public _context: PluginFeatureContext;

/** @internal */
public constructor() {
// reserved for future use
}

/** @internal */
public _context: PluginFeatureContext;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion apps/api-documenter/src/plugin/PluginLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ export class PluginLoader {
});

// Load the package
// eslint-disable-next-line @typescript-eslint/no-var-requires
const entryPoint: object | undefined = require(resolvedEntryPointPath);

if (!entryPoint) {
throw new Error('Invalid entry point');
}

const manifest: IApiDocumenterPluginManifest
// tslint:disable-next-line:no-string-literal
// eslint-disable-next-line dot-notation
= entryPoint['apiDocumenterPluginManifest'] as IApiDocumenterPluginManifest;

if (!manifest) {
Expand Down
6 changes: 0 additions & 6 deletions apps/api-documenter/tslint.json

This file was deleted.

12 changes: 12 additions & 0 deletions apps/api-extractor-model/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require("@rushstack/eslint-config/patch-eslint6");

module.exports = {
extends: [ "@rushstack/eslint-config" ],
parserOptions: { tsconfigRootDir: __dirname },

rules: {
// api-extractor-model uses namespaces to represent mixins
"@typescript-eslint/no-namespace": "off"
}
};
1 change: 1 addition & 0 deletions apps/api-extractor-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"devDependencies": {
"@microsoft/node-library-build": "6.3.0",
"@microsoft/rush-stack-compiler-3.4": "0.3.0",
"@rushstack/eslint-config": "0.4.0",
"@types/jest": "23.3.11",
"@types/node": "8.10.54",
"gulp": "~4.0.2",
Expand Down
20 changes: 10 additions & 10 deletions apps/api-extractor-model/src/items/ApiDeclaredItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,11 @@ export interface IApiDeclaredItemJson extends IApiDocumentedItemJson {
*
* @public
*/
// tslint:disable-next-line:interface-name
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export class ApiDeclaredItem extends ApiDocumentedItem {
private _excerptTokens: ExcerptToken[];
private _excerpt: Excerpt;

/** @override */
public static onDeserializeInto(options: Partial<IApiDeclaredItemOptions>, context: DeserializerContext,
jsonObject: IApiDeclaredItemJson): void {

super.onDeserializeInto(options, context, jsonObject);

options.excerptTokens = jsonObject.excerptTokens;
}

public constructor(options: IApiDeclaredItemOptions) {
super(options);

Expand All @@ -56,6 +47,15 @@ export class ApiDeclaredItem extends ApiDocumentedItem {
this._excerpt = new Excerpt(this.excerptTokens, { startIndex: 0, endIndex: this.excerptTokens.length });
}

/** @override */
public static onDeserializeInto(options: Partial<IApiDeclaredItemOptions>, context: DeserializerContext,
jsonObject: IApiDeclaredItemJson): void {

super.onDeserializeInto(options, context, jsonObject);

options.excerptTokens = jsonObject.excerptTokens;
}

/**
* The source code excerpt where the API item is declared.
*/
Expand Down
10 changes: 5 additions & 5 deletions apps/api-extractor-model/src/items/ApiDocumentedItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export interface IApiDocumentedItemJson extends IApiItemJson {
export class ApiDocumentedItem extends ApiItem {
private _tsdocComment: tsdoc.DocComment | undefined;

public constructor(options: IApiDocumentedItemOptions) {
super(options);
this._tsdocComment = options.docComment;
}

/** @override */
public static onDeserializeInto(options: Partial<IApiDocumentedItemOptions>, context: DeserializerContext,
jsonObject: IApiItemJson): void {
Expand All @@ -52,11 +57,6 @@ export class ApiDocumentedItem extends ApiItem {
}
}

public constructor(options: IApiDocumentedItemOptions) {
super(options);
this._tsdocComment = options.docComment;
}

public get tsdocComment(): tsdoc.DocComment | undefined {
return this._tsdocComment;
}
Expand Down
16 changes: 8 additions & 8 deletions apps/api-extractor-model/src/items/ApiItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export interface IApiItemJson {

// PRIVATE - Allows ApiItemContainerMixin to assign the parent.
//
// tslint:disable-next-line:variable-name
export const ApiItem_onParentChanged: unique symbol = Symbol('ApiItem._onAddToContainer');
export const apiItem_onParentChanged: unique symbol = Symbol('ApiItem._onAddToContainer');

/**
* The abstract base class for all members of an `ApiModel` object.
Expand All @@ -67,9 +66,14 @@ export class ApiItem {
private _canonicalReference: DeclarationReference | undefined;
private _parent: ApiItem | undefined;

public constructor(options: IApiItemOptions) {
// ("options" is not used here, but part of the inheritance pattern)
}

public static deserialize(jsonObject: IApiItemJson, context: DeserializerContext): ApiItem {
// The Deserializer class is coupled with a ton of other classes, so we delay loading it
// to avoid ES5 circular imports.
// eslint-disable-next-line @typescript-eslint/no-var-requires
const deserializerModule: typeof import('../model/Deserializer') = require('../model/Deserializer');
return deserializerModule.Deserializer.deserialize(context, jsonObject);
}
Expand All @@ -80,10 +84,6 @@ export class ApiItem {
// (implemented by subclasses)
}

public constructor(options: IApiItemOptions) {
// ("options" is not used here, but part of the inheritance pattern)
}

/** @virtual */
public serializeInto(jsonObject: Partial<IApiItemJson>): void {
jsonObject.kind = this.kind;
Expand Down Expand Up @@ -231,7 +231,7 @@ export class ApiItem {
// These functional forms don't have a proper name, so we don't append the "()" suffix
break;
default:
if (ApiParameterListMixin.isBaseClassOf(current)) { // tslint:disable-line:no-use-before-declare
if (ApiParameterListMixin.isBaseClassOf(current)) {
reversedParts.push('()');
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@ export class ApiItem {
*
* @internal
*/
public [ApiItem_onParentChanged](parent: ApiItem | undefined): void {
public [apiItem_onParentChanged](parent: ApiItem | undefined): void {
this._parent = parent;
this._canonicalReference = undefined;
}
Expand Down
12 changes: 6 additions & 6 deletions apps/api-extractor-model/src/items/ApiPropertyItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export class ApiPropertyItem extends ApiNameMixin(ApiReleaseTagMixin(ApiDeclared
*/
public readonly propertyTypeExcerpt: Excerpt;

public constructor(options: IApiPropertyItemOptions) {
super(options);

this.propertyTypeExcerpt = this.buildExcerpt(options.propertyTypeTokenRange);
}

/** @override */
public static onDeserializeInto(options: Partial<IApiPropertyItemOptions>, context: DeserializerContext,
jsonObject: IApiPropertyItemJson): void {
Expand All @@ -43,12 +49,6 @@ export class ApiPropertyItem extends ApiNameMixin(ApiReleaseTagMixin(ApiDeclared
options.propertyTypeTokenRange = jsonObject.propertyTypeTokenRange;
}

public constructor(options: IApiPropertyItemOptions) {
super(options);

this.propertyTypeExcerpt = this.buildExcerpt(options.propertyTypeTokenRange);
}

/**
* Returns true if this property should be documented as an event.
*
Expand Down
Loading

0 comments on commit 5627415

Please sign in to comment.