Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt prefer-readonly in JS/TS extension #165089

Merged
merged 2 commits into from Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -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/**
Expand Down
10 changes: 10 additions & 0 deletions 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"
}
};
5 changes: 0 additions & 5 deletions extensions/typescript-language-features/.eslintrc.json

This file was deleted.

Expand Up @@ -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<string, string> = {};
private _reporter: VsCodeTelemetryReporter;
private readonly _reporter: VsCodeTelemetryReporter;

constructor(reporter: VsCodeTelemetryReporter) {
this._reporter = reporter;
}
Expand Down
Expand Up @@ -13,8 +13,8 @@ interface ExperimentTypes {
}

export class ExperimentationService {
private _experimentationServicePromise: Promise<tas.IExperimentationService>;
private _telemetryReporter: IExperimentationTelemetryReporter;
private readonly _experimentationServicePromise: Promise<tas.IExperimentationService>;
private readonly _telemetryReporter: IExperimentationTelemetryReporter;

constructor(telemetryReporter: IExperimentationTelemetryReporter, id: string, version: string, globalState: vscode.Memento) {
this._telemetryReporter = telemetryReporter;
Expand Down
Expand Up @@ -36,7 +36,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensP

public constructor(
protected client: ITypeScriptServiceClient,
private cachedResponse: CachedResponse<Proto.NavTreeResponse>
private readonly cachedResponse: CachedResponse<Proto.NavTreeResponse>
) { }


Expand Down
Expand Up @@ -37,7 +37,7 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider

public constructor(
private readonly client: ITypeScriptServiceClient,
private cachedResponse: CachedResponse<Proto.NavTreeResponse>,
private readonly cachedResponse: CachedResponse<Proto.NavTreeResponse>,
) { }

public async provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentSymbol[] | undefined> {
Expand Down
Expand Up @@ -185,7 +185,7 @@ class SourceAddMissingImports extends SourceAction {

class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {

private static kindProviders = [
private static readonly kindProviders = [
SourceFixAll,
SourceRemoveUnused,
SourceAddMissingImports,
Expand Down
4 changes: 4 additions & 0 deletions 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;

Expand Down
Expand Up @@ -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,
Expand Down
Expand Up @@ -99,9 +99,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType

private readonly workspaceState: vscode.Memento;

private _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void };
private readonly _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void };
private _configuration: TypeScriptServiceConfiguration;
private pluginPathsProvider: TypeScriptPluginPathsProvider;
private readonly pluginPathsProvider: TypeScriptPluginPathsProvider;
private readonly _versionManager: TypeScriptVersionManager;

private readonly logger = new Logger();
Expand Down
Expand Up @@ -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);
Expand All @@ -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);
Expand Down