Skip to content

Commit e25f51a

Browse files
committed
Fix code for updated ESLint rules
1 parent 0a62b55 commit e25f51a

8 files changed

+25
-23
lines changed

.eslintrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
"@typescript-eslint/restrict-template-expressions": [
7070
"off"
7171
],
72+
"@typescript-eslint/prefer-nullish-coalescing": [
73+
"error",
74+
{
75+
"ignoreConditionalTests": true,
76+
"ignoreMixedLogicalExpressions": true
77+
}
78+
],
7279
"header/header": [
7380
2,
7481
"line",

src/features/DebugSession.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
559559
}
560560

561561
if (items.length === 0) {
562-
return Promise.reject("There are no PowerShell host processes to attach.");
562+
return Promise.reject(new Error("There are no PowerShell host processes to attach."));
563563
}
564564

565565
const options: QuickPickOptions = {

src/features/ExtensionCommands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
478478
if (vscode.window.activeTextEditor !== undefined) {
479479
vscode.window.activeTextEditor.selections = [
480480
new vscode.Selection(
481-
asCodePosition(details.selectionRange.start)!,
482-
asCodePosition(details.selectionRange.end)!),
481+
asCodePosition(details.selectionRange.start),
482+
asCodePosition(details.selectionRange.end)),
483483
];
484484
return EditorOperationResponse.Completed;
485485
}

src/features/NewFileOrProject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class NewFileOrProjectFeature extends LanguageClientConsumer {
5353
if (response.needsModuleInstall) {
5454
// TODO: Offer to install Plaster
5555
void this.logger.writeAndShowError("Plaster is not installed!");
56-
return Promise.reject<ITemplateQuickPickItem[]>("Plaster needs to be installed");
56+
return Promise.reject<ITemplateQuickPickItem[]>(new Error("Plaster needs to be installed"));
5757
}
5858

5959
let templates = response.templates.map<ITemplateQuickPickItem>(

src/languageClientConsumer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export abstract class LanguageClientConsumer {
5858
// Store the resolve function to be called in resetLanguageClient.
5959
LanguageClientConsumer.getLanguageClientResolve = resolve;
6060
// Reject the promise if the operation is cancelled.
61-
token.onCancellationRequested(() => { reject(); });
61+
token.onCancellationRequested(() => { reject(new Error("Cancelled PowerShell Extension Terminal start-up.")); });
6262
}
6363
);
6464
});

src/session.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export class SessionManager implements Middleware {
332332
this.debugEventHandler?.dispose();
333333

334334
if (this.PowerShellExeDetails === undefined) {
335-
return Promise.reject("Required PowerShellExeDetails undefined!");
335+
return Promise.reject(new Error("Required PowerShellExeDetails undefined!"));
336336
}
337337

338338
// TODO: It might not be totally necessary to update the session

test/core/platform.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ describe("Platform module", function () {
988988

989989
function getWinPSPath(systemDir: string): string {
990990
return path.join(
991-
testPlatform.environmentVars.windir!,
991+
testPlatform.environmentVars.windir,
992992
systemDir,
993993
"WindowsPowerShell",
994994
"v1.0",

test/runTestsInner.ts

+11-16
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,16 @@ function runTestsInner(testsRoot: string): Promise<void> {
6060
}
6161
});
6262

63-
return new Promise((c, e) => {
64-
try {
65-
mocha.run(failures => {
66-
console.log(`Mocha Run Finished with ${failures} failures.`);
67-
if (failures > 0) {
68-
throw new Error(`${failures} tests failed.`);
69-
} else {
70-
console.log("\n\n=====\nTest Runner STOP\n=====");
71-
c();
72-
return;
73-
}
74-
});
75-
} catch (err) {
76-
console.error("Failed to run tests");
77-
e(err);
78-
}
63+
return new Promise((resolve) => {
64+
mocha.run(failures => {
65+
console.log(`Mocha Run Finished with ${failures} failures.`);
66+
if (failures > 0) {
67+
throw new Error(`${failures} tests failed.`);
68+
} else {
69+
console.log("\n\n=====\nTest Runner STOP\n=====");
70+
resolve();
71+
return;
72+
}
73+
});
7974
});
8075
}

0 commit comments

Comments
 (0)