Skip to content

Commit 44441de

Browse files
authored
Adopt prefer-readonly in JS/TS extension (microsoft#165089)
1 parent 9ccc7e3 commit 44441de

File tree

12 files changed

+36
-20
lines changed

12 files changed

+36
-20
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
**/extensions/notebook-renderers/renderer-out/index.js
1414
**/extensions/simple-browser/media/index.js
1515
**/extensions/typescript-language-features/test-workspace/**
16+
**/extensions/typescript-language-features/extension.webpack.config.js
17+
**/extensions/typescript-language-features/extension-browser.webpack.config.js
1618
**/extensions/vscode-api-tests/testWorkspace/**
1719
**/extensions/vscode-api-tests/testWorkspace2/**
1820
**/fixtures/**
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
"parserOptions": {
3+
"tsconfigRootDir": __dirname,
4+
"project": "./tsconfig.json"
5+
},
6+
"rules": {
7+
"@typescript-eslint/prefer-optional-chain": "warn",
8+
"@typescript-eslint/prefer-readonly": "warn"
9+
}
10+
};

extensions/typescript-language-features/.eslintrc.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

extensions/typescript-language-features/src/experimentTelemetryReporter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export interface IExperimentationTelemetryReporter extends tas.IExperimentationT
1616
* but will only do so when passed to an {@link ExperimentationService}.
1717
*/
1818

19-
export class ExperimentationTelemetryReporter
20-
implements IExperimentationTelemetryReporter {
19+
export class ExperimentationTelemetryReporter implements IExperimentationTelemetryReporter {
20+
2121
private _sharedProperties: Record<string, string> = {};
22-
private _reporter: VsCodeTelemetryReporter;
22+
private readonly _reporter: VsCodeTelemetryReporter;
23+
2324
constructor(reporter: VsCodeTelemetryReporter) {
2425
this._reporter = reporter;
2526
}

extensions/typescript-language-features/src/experimentationService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ interface ExperimentTypes {
1313
}
1414

1515
export class ExperimentationService {
16-
private _experimentationServicePromise: Promise<tas.IExperimentationService>;
17-
private _telemetryReporter: IExperimentationTelemetryReporter;
16+
private readonly _experimentationServicePromise: Promise<tas.IExperimentationService>;
17+
private readonly _telemetryReporter: IExperimentationTelemetryReporter;
1818

1919
constructor(telemetryReporter: IExperimentationTelemetryReporter, id: string, version: string, globalState: vscode.Memento) {
2020
this._telemetryReporter = telemetryReporter;

extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensP
3636

3737
public constructor(
3838
protected client: ITypeScriptServiceClient,
39-
private cachedResponse: CachedResponse<Proto.NavTreeResponse>
39+
private readonly cachedResponse: CachedResponse<Proto.NavTreeResponse>
4040
) { }
4141

4242

extensions/typescript-language-features/src/languageFeatures/documentSymbol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider
3737

3838
public constructor(
3939
private readonly client: ITypeScriptServiceClient,
40-
private cachedResponse: CachedResponse<Proto.NavTreeResponse>,
40+
private readonly cachedResponse: CachedResponse<Proto.NavTreeResponse>,
4141
) { }
4242

4343
public async provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentSymbol[] | undefined> {

extensions/typescript-language-features/src/languageFeatures/fixAll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class SourceAddMissingImports extends SourceAction {
185185

186186
class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
187187

188-
private static kindProviders = [
188+
private static readonly kindProviders = [
189189
SourceFixAll,
190190
SourceRemoveUnused,
191191
SourceAddMissingImports,

extensions/typescript-language-features/src/protocol.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
15
import * as ts from 'typescript/lib/tsserverlibrary';
26
export = ts.server.protocol;
37

extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export class WorkerServerProcess implements TsServerProcess {
3434
]);
3535
}
3636

37-
private _onDataHandlers = new Set<(data: Proto.Response) => void>();
38-
private _onErrorHandlers = new Set<(err: Error) => void>();
39-
private _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>();
37+
private readonly _onDataHandlers = new Set<(data: Proto.Response) => void>();
38+
private readonly _onErrorHandlers = new Set<(err: Error) => void>();
39+
private readonly _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>();
4040

4141
public constructor(
4242
private readonly worker: Worker,

0 commit comments

Comments
 (0)