Skip to content

Commit

Permalink
refactor: Refactored to use an extension controller + require return …
Browse files Browse the repository at this point in the history
…types (#92)

- Refactored `extension` module to use a controller class. This should
make things easier to test and encourages better architecture
- Enabled linting rule to require return types + fixed offending code

supports #79
  • Loading branch information
bmingles authored Aug 12, 2024
1 parent b503a9f commit 83050dc
Show file tree
Hide file tree
Showing 27 changed files with 732 additions and 380 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"overrides": [
{
"files": ["*.ts"],
// Since parserOptions.project is used, can't include files outside of
// the listed tsconfig files and seems silly to add a tsconfig just for
// the one file. It will still be linted by the base config above. It just
// won't be included in this overrides section.
"excludedFiles": ["vitest.config.ts"],
"parserOptions": {
"project": [
"./tsconfig.json",
Expand All @@ -29,7 +34,8 @@

"rules": {
"no-return-await": "off",
"@typescript-eslint/return-await": "error"
"@typescript-eslint/return-await": "error",
"@typescript-eslint/explicit-function-return-type": "error"
}
}
],
Expand Down
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ src/**
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/tsconfig.unit.json
**/.eslintrc.json
**/*.map
**/*.ts
**/__mocks__/**
e2e/**
test-reports/**
6 changes: 4 additions & 2 deletions e2e/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const PYTHON_AND_GROOVY_SERVER_CONFIG = [
/**
* Find the connection status bar item if it is visible.
*/
export async function findConnectionStatusBarItem() {
export async function findConnectionStatusBarItem(): Promise<
WebdriverIO.Element | undefined
> {
const workbench = await browser.getWorkbench();

return workbench.getStatusBar().getItem(
Expand All @@ -23,7 +25,7 @@ export async function findConnectionStatusBarItem() {
/**
* Check if the connection status bar item is visible.
*/
export async function hasConnectionStatusBarItem() {
export async function hasConnectionStatusBarItem(): Promise<boolean> {
return (await findConnectionStatusBarItem()) != null;
}

Expand Down
3 changes: 2 additions & 1 deletion e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"moduleResolution": "node",
"esModuleInterop": true
},
// Override ../tsconfig.json `exclude`
// Override ../tsconfig.json `include` and `exclude`
"include": ["."],
"exclude": ["node_modules"]
}
10 changes: 10 additions & 0 deletions src/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Mock `vscode` module. Note that `vi.mock('vscode')` has to be explicitly
* called in any test module needing to use this mock. It will not be loaded
* automatically.
*/
import { vi } from 'vitest';

export const workspace = {
getConfiguration: vi.fn().mockReturnValue(new Map()),
};
2 changes: 1 addition & 1 deletion src/dh/dhc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function getEmbedWidgetUrl(
serverUrl: string,
title: string,
psk?: string
) {
): string {
serverUrl = serverUrl.replace(/\/$/, '');
return `${serverUrl}/iframe/widget/?name=${title}${psk ? `&psk=${psk}` : ''}`;
}
Expand Down
Loading

0 comments on commit 83050dc

Please sign in to comment.