diff --git a/.eslintignore b/.eslintignore index af5f9a4940b63..fea65b495873f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -13,6 +13,8 @@ **/extensions/notebook-renderers/renderer-out/index.js **/extensions/simple-browser/media/index.js **/extensions/typescript-language-features/test-workspace/** +**/extensions/typescript-language-features/extension.webpack.config.js +**/extensions/typescript-language-features/extension-browser.webpack.config.js **/extensions/vscode-api-tests/testWorkspace/** **/extensions/vscode-api-tests/testWorkspace2/** **/fixtures/** diff --git a/extensions/typescript-language-features/.eslintrc.js b/extensions/typescript-language-features/.eslintrc.js new file mode 100644 index 0000000000000..e910c2f25102e --- /dev/null +++ b/extensions/typescript-language-features/.eslintrc.js @@ -0,0 +1,10 @@ +module.exports = { + "parserOptions": { + "tsconfigRootDir": __dirname, + "project": "./tsconfig.json" + }, + "rules": { + "@typescript-eslint/prefer-optional-chain": "warn", + "@typescript-eslint/prefer-readonly": "warn" + } +}; diff --git a/extensions/typescript-language-features/.eslintrc.json b/extensions/typescript-language-features/.eslintrc.json deleted file mode 100644 index f7c6c1b495b5c..0000000000000 --- a/extensions/typescript-language-features/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "@typescript-eslint/prefer-optional-chain": "warn" - } -} diff --git a/extensions/typescript-language-features/src/experimentTelemetryReporter.ts b/extensions/typescript-language-features/src/experimentTelemetryReporter.ts index d756130076162..ddd643fbc882f 100644 --- a/extensions/typescript-language-features/src/experimentTelemetryReporter.ts +++ b/extensions/typescript-language-features/src/experimentTelemetryReporter.ts @@ -16,10 +16,11 @@ export interface IExperimentationTelemetryReporter extends tas.IExperimentationT * but will only do so when passed to an {@link ExperimentationService}. */ -export class ExperimentationTelemetryReporter - implements IExperimentationTelemetryReporter { +export class ExperimentationTelemetryReporter implements IExperimentationTelemetryReporter { + private _sharedProperties: Record = {}; - private _reporter: VsCodeTelemetryReporter; + private readonly _reporter: VsCodeTelemetryReporter; + constructor(reporter: VsCodeTelemetryReporter) { this._reporter = reporter; } diff --git a/extensions/typescript-language-features/src/experimentationService.ts b/extensions/typescript-language-features/src/experimentationService.ts index 1f3b1fbd73b79..86d1fd42b55a7 100644 --- a/extensions/typescript-language-features/src/experimentationService.ts +++ b/extensions/typescript-language-features/src/experimentationService.ts @@ -13,8 +13,8 @@ interface ExperimentTypes { } export class ExperimentationService { - private _experimentationServicePromise: Promise; - private _telemetryReporter: IExperimentationTelemetryReporter; + private readonly _experimentationServicePromise: Promise; + private readonly _telemetryReporter: IExperimentationTelemetryReporter; constructor(telemetryReporter: IExperimentationTelemetryReporter, id: string, version: string, globalState: vscode.Memento) { this._telemetryReporter = telemetryReporter; diff --git a/extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts b/extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts index 74377b29f74a9..9605eb01693f3 100644 --- a/extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts +++ b/extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts @@ -36,7 +36,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensP public constructor( protected client: ITypeScriptServiceClient, - private cachedResponse: CachedResponse + private readonly cachedResponse: CachedResponse ) { } diff --git a/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts b/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts index 0a17b83678b84..1513229529dc1 100644 --- a/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts +++ b/extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts @@ -37,7 +37,7 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider public constructor( private readonly client: ITypeScriptServiceClient, - private cachedResponse: CachedResponse, + private readonly cachedResponse: CachedResponse, ) { } public async provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { diff --git a/extensions/typescript-language-features/src/languageFeatures/fixAll.ts b/extensions/typescript-language-features/src/languageFeatures/fixAll.ts index 1fad8f4eb610a..fa64f520ad8a3 100644 --- a/extensions/typescript-language-features/src/languageFeatures/fixAll.ts +++ b/extensions/typescript-language-features/src/languageFeatures/fixAll.ts @@ -185,7 +185,7 @@ class SourceAddMissingImports extends SourceAction { class TypeScriptAutoFixProvider implements vscode.CodeActionProvider { - private static kindProviders = [ + private static readonly kindProviders = [ SourceFixAll, SourceRemoveUnused, SourceAddMissingImports, diff --git a/extensions/typescript-language-features/src/protocol.d.ts b/extensions/typescript-language-features/src/protocol.d.ts index 1aec9e082ed33..38345971fc88e 100644 --- a/extensions/typescript-language-features/src/protocol.d.ts +++ b/extensions/typescript-language-features/src/protocol.d.ts @@ -1,3 +1,7 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ import * as ts from 'typescript/lib/tsserverlibrary'; export = ts.server.protocol; diff --git a/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts b/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts index 5fdbbb6d2f7ab..302fe2bbb3032 100644 --- a/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts +++ b/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts @@ -34,9 +34,9 @@ export class WorkerServerProcess implements TsServerProcess { ]); } - private _onDataHandlers = new Set<(data: Proto.Response) => void>(); - private _onErrorHandlers = new Set<(err: Error) => void>(); - private _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>(); + private readonly _onDataHandlers = new Set<(data: Proto.Response) => void>(); + private readonly _onErrorHandlers = new Set<(err: Error) => void>(); + private readonly _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>(); public constructor( private readonly worker: Worker, diff --git a/extensions/typescript-language-features/src/typescriptServiceClient.ts b/extensions/typescript-language-features/src/typescriptServiceClient.ts index 012942c3c559b..99b263365ec9f 100644 --- a/extensions/typescript-language-features/src/typescriptServiceClient.ts +++ b/extensions/typescript-language-features/src/typescriptServiceClient.ts @@ -99,9 +99,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType private readonly workspaceState: vscode.Memento; - private _onReady?: { promise: Promise; resolve: () => void; reject: () => void }; + private readonly _onReady?: { promise: Promise; resolve: () => void; reject: () => void }; private _configuration: TypeScriptServiceConfiguration; - private pluginPathsProvider: TypeScriptPluginPathsProvider; + private readonly pluginPathsProvider: TypeScriptPluginPathsProvider; private readonly _versionManager: TypeScriptVersionManager; private readonly logger = new Logger(); diff --git a/extensions/typescript-language-features/src/ui/jsNodeWalkthrough.electron.ts b/extensions/typescript-language-features/src/ui/jsNodeWalkthrough.electron.ts index 854c2ff3c3337..a1a6bd2ac2d54 100644 --- a/extensions/typescript-language-features/src/ui/jsNodeWalkthrough.electron.ts +++ b/extensions/typescript-language-features/src/ui/jsNodeWalkthrough.electron.ts @@ -50,7 +50,9 @@ export class CreateNewJSFileCommand { public static readonly id = 'javascript-walkthrough.commands.createJsFile'; public readonly id = CreateNewJSFileCommand.id; - constructor(private walkthroughState: JsWalkthroughState) { } + constructor( + private readonly walkthroughState: JsWalkthroughState + ) { } public execute() { createNewJSFile(this.walkthroughState); @@ -61,7 +63,9 @@ export class DebugJsFileCommand { public static readonly id = 'javascript-walkthrough.commands.debugJsFile'; public readonly id = DebugJsFileCommand.id; - constructor(private walkthroughState: JsWalkthroughState) { } + constructor( + private readonly walkthroughState: JsWalkthroughState + ) { } public execute() { debugJsFile(this.walkthroughState);