Skip to content

Commit

Permalink
Fix code for updated ESLint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Jan 26, 2024
1 parent 0a62b55 commit e25f51a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
"@typescript-eslint/restrict-template-expressions": [
"off"
],
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{
"ignoreConditionalTests": true,
"ignoreMixedLogicalExpressions": true
}
],
"header/header": [
2,
"line",
Expand Down
2 changes: 1 addition & 1 deletion src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
}

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

const options: QuickPickOptions = {
Expand Down
4 changes: 2 additions & 2 deletions src/features/ExtensionCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
if (vscode.window.activeTextEditor !== undefined) {
vscode.window.activeTextEditor.selections = [
new vscode.Selection(
asCodePosition(details.selectionRange.start)!,
asCodePosition(details.selectionRange.end)!),
asCodePosition(details.selectionRange.start),
asCodePosition(details.selectionRange.end)),
];
return EditorOperationResponse.Completed;
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/NewFileOrProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class NewFileOrProjectFeature extends LanguageClientConsumer {
if (response.needsModuleInstall) {
// TODO: Offer to install Plaster
void this.logger.writeAndShowError("Plaster is not installed!");
return Promise.reject<ITemplateQuickPickItem[]>("Plaster needs to be installed");
return Promise.reject<ITemplateQuickPickItem[]>(new Error("Plaster needs to be installed"));
}

let templates = response.templates.map<ITemplateQuickPickItem>(
Expand Down
2 changes: 1 addition & 1 deletion src/languageClientConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export abstract class LanguageClientConsumer {
// Store the resolve function to be called in resetLanguageClient.
LanguageClientConsumer.getLanguageClientResolve = resolve;
// Reject the promise if the operation is cancelled.
token.onCancellationRequested(() => { reject(); });
token.onCancellationRequested(() => { reject(new Error("Cancelled PowerShell Extension Terminal start-up.")); });
}
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class SessionManager implements Middleware {
this.debugEventHandler?.dispose();

if (this.PowerShellExeDetails === undefined) {
return Promise.reject("Required PowerShellExeDetails undefined!");
return Promise.reject(new Error("Required PowerShellExeDetails undefined!"));
}

// TODO: It might not be totally necessary to update the session
Expand Down
2 changes: 1 addition & 1 deletion test/core/platform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ describe("Platform module", function () {

function getWinPSPath(systemDir: string): string {
return path.join(
testPlatform.environmentVars.windir!,
testPlatform.environmentVars.windir,
systemDir,
"WindowsPowerShell",
"v1.0",
Expand Down
27 changes: 11 additions & 16 deletions test/runTestsInner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,16 @@ function runTestsInner(testsRoot: string): Promise<void> {
}
});

return new Promise((c, e) => {
try {
mocha.run(failures => {
console.log(`Mocha Run Finished with ${failures} failures.`);
if (failures > 0) {
throw new Error(`${failures} tests failed.`);
} else {
console.log("\n\n=====\nTest Runner STOP\n=====");
c();
return;
}
});
} catch (err) {
console.error("Failed to run tests");
e(err);
}
return new Promise((resolve) => {
mocha.run(failures => {
console.log(`Mocha Run Finished with ${failures} failures.`);
if (failures > 0) {
throw new Error(`${failures} tests failed.`);
} else {
console.log("\n\n=====\nTest Runner STOP\n=====");
resolve();
return;
}
});
});
}

0 comments on commit e25f51a

Please sign in to comment.