Skip to content

Commit 98af0b8

Browse files
committed
Fix remaining ESLint warnings and errors
1 parent b072a46 commit 98af0b8

18 files changed

+102
-32
lines changed

src/features/CodeActions.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export class CodeActionsFeature implements vscode.Disposable {
1010
private showDocumentationCommand: vscode.Disposable;
1111

1212
constructor(private log: ILogger) {
13+
// TODO: What type is `edit`, what uses this, and is it working?
14+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1315
this.applyEditsCommand = vscode.commands.registerCommand("PowerShell.ApplyCodeActionEdits", (edit: any) => {
1416
Window.activeTextEditor?.edit((editBuilder) => {
1517
editBuilder.replace(
@@ -23,7 +25,7 @@ export class CodeActionsFeature implements vscode.Disposable {
2325
});
2426

2527
this.showDocumentationCommand =
26-
vscode.commands.registerCommand("PowerShell.ShowCodeActionDocumentation", (ruleName: any) => {
28+
vscode.commands.registerCommand("PowerShell.ShowCodeActionDocumentation", (ruleName: string) => {
2729
this.showRuleDocumentation(ruleName);
2830
});
2931
}

src/features/DebugSession.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ interface IProcessItem extends vscode.QuickPickItem {
338338
pid: string; // payload for the QuickPick UI
339339
}
340340

341+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
342+
interface IGetPSHostProcessesArguments {
343+
}
344+
341345
interface IPSHostProcessInfo {
342346
processName: string;
343347
processId: string;
@@ -346,7 +350,7 @@ interface IPSHostProcessInfo {
346350
}
347351

348352
export const GetPSHostProcessesRequestType =
349-
new RequestType<any, IPSHostProcessInfo[], string>("powerShell/getPSHostProcesses");
353+
new RequestType<IGetPSHostProcessesArguments, IPSHostProcessInfo[], string>("powerShell/getPSHostProcesses");
350354

351355
export class PickPSHostProcessFeature extends LanguageClientConsumer {
352356

@@ -462,14 +466,18 @@ interface IRunspaceItem extends vscode.QuickPickItem {
462466
id: string; // payload for the QuickPick UI
463467
}
464468

469+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
470+
interface IGetRunspaceRequestArguments {
471+
}
472+
465473
interface IRunspace {
466474
id: number;
467475
name: string;
468476
availability: string;
469477
}
470478

471479
export const GetRunspaceRequestType =
472-
new RequestType<any, IRunspace[], string>("powerShell/getRunspace");
480+
new RequestType<IGetRunspaceRequestArguments, IRunspace[], string>("powerShell/getRunspace");
473481

474482
export class PickRunspaceFeature extends LanguageClientConsumer {
475483

src/features/ExpandAlias.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import Window = vscode.window;
66
import { RequestType } from "vscode-languageclient";
77
import { LanguageClientConsumer } from "../languageClientConsumer";
88

9-
export const ExpandAliasRequestType = new RequestType<any, any, void>("powerShell/expandAlias");
9+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
10+
interface IExpandAliasRequestArguments {
11+
}
12+
13+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
14+
interface IExpandAliasRequestResponse {
15+
text: string
16+
}
17+
18+
export const ExpandAliasRequestType = new RequestType<IExpandAliasRequestArguments, IExpandAliasRequestResponse, void>("powerShell/expandAlias");
1019

1120
export class ExpandAliasFeature extends LanguageClientConsumer {
1221
private command: vscode.Disposable;
@@ -24,7 +33,7 @@ export class ExpandAliasFeature extends LanguageClientConsumer {
2433
const sls = selection.start;
2534
const sle = selection.end;
2635

27-
let text: string | any[];
36+
let text: string;
2837
let range: vscode.Range | vscode.Position;
2938

3039
if ((sls.character === sle.character) && (sls.line === sle.line)) {

src/features/ExtensionCommands.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
431431

432432
let newFileAbsolutePath: string;
433433
switch (currentFileUri.scheme) {
434-
case "file":
434+
case "file": {
435435
// If the file to save can't be found, just complete the request
436436
if (!this.findTextDocument(this.normalizeFilePath(currentFileUri.fsPath))) {
437437
await this.log.writeAndShowError(`File to save not found: ${currentFileUri.fsPath}.`);
@@ -454,9 +454,9 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
454454
// If not, interpret the path as relative to the current file
455455
newFileAbsolutePath = path.join(path.dirname(currentFileUri.fsPath), saveFileDetails.newPath);
456456
}
457-
break;
457+
break; }
458458

459-
case "untitled":
459+
case "untitled": {
460460
// We need a new name to save an untitled file
461461
if (!saveFileDetails.newPath) {
462462
// TODO: Create a class handle vscode warnings and errors so we can warn easily
@@ -488,15 +488,15 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
488488
}
489489
newFileAbsolutePath = path.join(workspaceRootUri.fsPath, saveFileDetails.newPath);
490490
}
491-
break;
491+
break; }
492492

493-
default:
493+
default: {
494494
// Other URI schemes are not supported
495495
const msg = JSON.stringify(saveFileDetails);
496496
this.log.writeVerbose(
497497
`<${ExtensionCommandsFeature.name}>: Saving a document with scheme '${currentFileUri.scheme}' ` +
498-
`is currently unsupported. Message: '${msg}'`);
499-
return EditorOperationResponse.Completed;
498+
`is currently unsupported. Message: '${msg}'`);
499+
return EditorOperationResponse.Completed; }
500500
}
501501

502502
await this.saveDocumentContentToAbsolutePath(currentFileUri, newFileAbsolutePath);

src/features/ExternalApi.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export class ExternalApiFeature extends LanguageClientConsumer implements IPower
5959
public registerExternalExtension(id: string, apiVersion = "v1"): string {
6060
this.log.writeDiagnostic(`Registering extension '${id}' for use with API version '${apiVersion}'.`);
6161

62-
for (const [_, externalExtension] of ExternalApiFeature.registeredExternalExtension) {
62+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
63+
for (const [_name, externalExtension] of ExternalApiFeature.registeredExternalExtension) {
6364
if (externalExtension.id === id) {
6465
const message = `The extension '${id}' is already registered.`;
6566
this.log.writeWarning(message);

src/features/FindModule.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// TODO: PSES does not currently support findModule...so this whole thing is broken!
5+
46
import vscode = require("vscode");
57
import { RequestType } from "vscode-languageclient";
68
import QuickPickItem = vscode.QuickPickItem;
79
import { LanguageClientConsumer } from "../languageClientConsumer";
810

11+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
12+
interface IFindModuleRequestArguments {
13+
}
14+
15+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
16+
interface IModule {
17+
name: string,
18+
description: string
19+
}
20+
921
export const FindModuleRequestType =
10-
new RequestType<any, any, void>("powerShell/findModule");
22+
new RequestType<IFindModuleRequestArguments, IModule[], void>("powerShell/findModule");
1123

1224
export const InstallModuleRequestType =
1325
new RequestType<string, void, void>("powerShell/installModule");
@@ -66,12 +78,8 @@ export class FindModuleFeature extends LanguageClientConsumer {
6678
return Promise.resolve("");
6779
}
6880

69-
if (modules !== undefined) {
70-
for (const item in modules) {
71-
if (modules.hasOwnProperty(item)) {
72-
items.push({ label: modules[item].name, description: modules[item].description });
73-
}
74-
}
81+
for (const module of modules ?? []) {
82+
items.push({ label: module.name, description: module.description });
7583
}
7684

7785
if (items.length === 0) {

src/features/GenerateBugReport.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os = require("os");
55
import vscode = require("vscode");
6+
import child_process = require("child_process");
67
import { SessionManager } from "../session";
78
import Settings = require("../settings");
89

@@ -79,6 +80,7 @@ ${this.generateExtensionTable(extensions)}
7980
this.command.dispose();
8081
}
8182

83+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8284
private generateExtensionTable(installedExtensions: vscode.Extension<any>[]): string {
8385
if (!installedExtensions.length) {
8486
return "none";
@@ -104,17 +106,20 @@ ${tableHeader}\n${table};
104106
return extensionTable;
105107
}
106108

107-
private getRuntimeInfo() {
108-
const powerShellExePath = this.sessionManager.PowerShellExeDetails?.exePath;
109+
private getRuntimeInfo(): string | undefined {
110+
if (this.sessionManager.PowerShellExeDetails === undefined) {
111+
return;
112+
}
113+
114+
const powerShellExePath = this.sessionManager.PowerShellExeDetails.exePath;
109115
const powerShellArgs = [
110116
"-NoProfile",
111117
"-Command",
112118
"$PSVersionString = \"|Name|Value|\n\"; $PSVersionString += \"|---|---|\n\"; $PSVersionTable.keys | " +
113119
"ForEach-Object { $PSVersionString += \"|$_|$($PSVersionTable.Item($_))|\n\" }; $PSVersionString",
114120
];
115121

116-
const spawn = require("child_process").spawnSync;
117-
const child = spawn(powerShellExePath, powerShellArgs);
122+
const child = child_process.spawnSync(powerShellExePath, powerShellArgs);
118123
return child.stdout.toString().replace(";", ",");
119124
}
120125
}

src/features/GetCommands.ts

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class Command extends vscode.TreeItem {
139139
};
140140
}
141141

142+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
142143
public async getChildren(_element?: any): Promise<Command[]> {
143144
return [];
144145
// Returning an empty array because we need to return something.

src/features/HelpCompletion.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ import { Logger } from "../logging";
1111
import Settings = require("../settings");
1212
import { LanguageClientConsumer } from "../languageClientConsumer";
1313

14+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
15+
interface ICommentHelpRequestArguments {
16+
}
17+
18+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
19+
interface ICommentHelpRequestResponse {
20+
content: string[]
21+
}
22+
1423
export const CommentHelpRequestType =
15-
new RequestType<any, any, void>("powerShell/getCommentHelp");
24+
new RequestType<ICommentHelpRequestArguments, ICommentHelpRequestResponse, void>("powerShell/getCommentHelp");
1625

1726
enum SearchState { Searching, Locked, Found }
1827

@@ -175,7 +184,7 @@ class HelpCompletionProvider {
175184
// Trim the last empty line and join the strings.
176185
const lines: string[] = result.content;
177186
const text = lines
178-
.map((x) => (x as any).trimLeft())
187+
.map((x) => x.trimLeft())
179188
.join(this.getEOL(doc.eol));
180189

181190
const snippetString = new SnippetString(text);

src/features/NewFileOrProject.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ interface IGetProjectTemplatesResponseBody {
193193
templates: ITemplateDetails[];
194194
}
195195

196+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
197+
interface INewProjectFromTemplateRequestArguments {
198+
}
199+
196200
export const NewProjectFromTemplateRequestType =
197-
new RequestType<any, INewProjectFromTemplateResponseBody, string>(
201+
new RequestType<INewProjectFromTemplateRequestArguments, INewProjectFromTemplateResponseBody, string>(
198202
"powerShell/newProjectFromTemplate");
199203

200204
interface INewProjectFromTemplateResponseBody {

src/features/OpenInISE.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class OpenInISEFeature implements vscode.Disposable {
1818
const uri = document.uri;
1919
let ISEPath = process.env.windir;
2020

21-
if (process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")) {
21+
if (process.env.PROCESSOR_ARCHITEW6432 !== undefined) {
2222
ISEPath += "\\Sysnative";
2323
} else {
2424
ISEPath += "\\System32";

src/features/PesterTests.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ export class PesterTestsFeature implements vscode.Disposable {
4848
launchType: LaunchType,
4949
fileUri: vscode.Uri): Promise<boolean> {
5050

51-
const uriString = (fileUri || vscode.window.activeTextEditor?.document.uri).toString();
51+
if (fileUri === undefined && vscode.window.activeTextEditor === undefined) {
52+
return false;
53+
}
54+
55+
const uriString = (fileUri || vscode.window.activeTextEditor!.document.uri).toString();
5256
const launchConfig = this.createLaunchConfig(uriString, launchType);
5357
return this.launch(launchConfig);
5458
}

src/features/ShowHelp.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ import vscode = require("vscode");
55
import { NotificationType } from "vscode-languageclient";
66
import { LanguageClientConsumer } from "../languageClientConsumer";
77

8+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
9+
interface IShowHelpNotificationArguments {
10+
}
11+
812
export const ShowHelpNotificationType =
9-
new NotificationType<any>("powerShell/showHelp");
13+
new NotificationType<IShowHelpNotificationArguments>("powerShell/showHelp");
1014

1115
export class ShowHelpFeature extends LanguageClientConsumer {
1216
private command: vscode.Disposable;

src/features/UpdatePowerShell.ts

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class GitHubReleaseInformation {
5050

5151
// For preview, we grab all the releases and then grab the first prerelease.
5252
const releaseJson = preview
53+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5354
? (await response.json()).find((release: any) => release.prerelease)
5455
: await response.json();
5556

@@ -59,8 +60,11 @@ export class GitHubReleaseInformation {
5960

6061
public version: semver.SemVer;
6162
public isPreview = false;
63+
// TODO: Establish a type for the assets.
64+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6265
public assets: any[];
6366

67+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6468
public constructor(version: string | semver.SemVer, assets: any[] = []) {
6569
this.version = semver.parse(version)!;
6670

@@ -128,6 +132,7 @@ export async function InvokePowerShellUpdateCheck(
128132
const msiMatcher = arch === "x86" ?
129133
"win-x86.msi" : "win-x64.msi";
130134

135+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
131136
const asset = release.assets.filter((a: any) => a.name.indexOf(msiMatcher) >= 0)[0];
132137
const msiDownloadPath = path.join(os.tmpdir(), asset.name);
133138

src/main.ts

+8
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
6868
vscode.languages.setLanguageConfiguration(
6969
PowerShellLanguageId,
7070
{
71+
// TODO: Remove the useless escapes
72+
// eslint-disable-next-line no-useless-escape
7173
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\'\"\,\.\<\>\/\?\s]+)/g,
7274

7375
indentationRules: {
@@ -91,27 +93,33 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
9193
onEnterRules: [
9294
{
9395
// e.g. /** | */
96+
// eslint-disable-next-line no-useless-escape
9497
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
98+
// eslint-disable-next-line no-useless-escape
9599
afterText: /^\s*\*\/$/,
96100
action: { indentAction: vscode.IndentAction.IndentOutdent, appendText: " * " },
97101
},
98102
{
99103
// e.g. /** ...|
104+
// eslint-disable-next-line no-useless-escape
100105
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
101106
action: { indentAction: vscode.IndentAction.None, appendText: " * " },
102107
},
103108
{
104109
// e.g. * ...|
110+
// eslint-disable-next-line no-useless-escape
105111
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
106112
action: { indentAction: vscode.IndentAction.None, appendText: "* " },
107113
},
108114
{
109115
// e.g. */|
116+
// eslint-disable-next-line no-useless-escape
110117
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
111118
action: { indentAction: vscode.IndentAction.None, removeText: 1 },
112119
},
113120
{
114121
// e.g. *-----*/|
122+
// eslint-disable-next-line no-useless-escape
115123
beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,
116124
action: { indentAction: vscode.IndentAction.None, removeText: 1 },
117125
},

src/platform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function getPlatformDetails(): IPlatformDetails {
5656

5757
return {
5858
operatingSystem,
59-
isOS64Bit: isProcess64Bit || process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432"),
59+
isOS64Bit: isProcess64Bit || (process.env.PROCESSOR_ARCHITEW6432 !== undefined),
6060
isProcess64Bit,
6161
};
6262
}

0 commit comments

Comments
 (0)