@@ -25,7 +25,7 @@
Loading
25 25
import webviewContent from "~/../assets/ui/index.html";
26 26
27 27
export namespace Webview {
28 -
	export const openSettingsPage = (settings: ISettings) => {
28 +
	export const openSettingsPage = (settings: ISettings): WebviewPanel => {
29 29
		return createPanel({
30 30
			data: {
31 31
				settings,
@@ -43,7 +43,7 @@
Loading
43 43
		});
44 44
	};
45 45
46 -
	export const openErrorPage = (error: Error) => {
46 +
	export const openErrorPage = (error: Error): WebviewPanel => {
47 47
		return createPanel({
48 48
			data: error.message,
49 49
			id: "error",
@@ -51,7 +51,7 @@
Loading
51 51
		});
52 52
	};
53 53
54 -
	export const openLandingPage = () => {
54 +
	export const openLandingPage = (): WebviewPanel => {
55 55
		return createPanel({
56 56
			id: "landing",
57 57
			title: "Welcome to Syncify",
@@ -115,7 +115,7 @@
Loading
115 115
		token: string;
116 116
		user: string;
117 117
		provider: string;
118 -
	}) => {
118 +
	}): WebviewPanel => {
119 119
		return createPanel({
120 120
			id: "repo",
121 121
			title: "Configure Repository",
@@ -156,6 +156,7 @@
Loading
156 156
		if (page) {
157 157
			page.webview.html = generateContent(
158 158
				page.webview.asWebviewUri(pwdUri).toString(),
159 +
				page.webview.cspSource,
159 160
				id,
160 161
				data,
161 162
			);
@@ -178,6 +179,7 @@
Loading
178 179
179 180
		panel.webview.html = generateContent(
180 181
			panel.webview.asWebviewUri(pwdUri).toString(),
182 +
			panel.webview.cspSource,
181 183
			id,
182 184
			data,
183 185
		);
@@ -192,9 +194,15 @@
Loading
192 194
		return panel;
193 195
	};
194 196
195 -
	const generateContent = (pwd: string, id: string, data: any) => {
197 +
	const generateContent = (
198 +
		pwd: string,
199 +
		csp: string,
200 +
		id: string,
201 +
		data: any,
202 +
	): string => {
196 203
		return webviewContent
197 204
			.replace(/@PWD/g, pwd)
205 +
			.replace(/@CSP/g, csp)
198 206
			.replace(/@PAGE/g, id)
199 207
			.replace(/@DATA/g, encodeURIComponent(JSON.stringify(data)));
200 208
	};

@@ -2,7 +2,7 @@
Loading
2 2
import { tmpdir } from "os";
3 3
import createGit from "simple-git/promise";
4 4
5 -
export async function checkGit(required: string) {
5 +
export async function checkGit(required: string): Promise<boolean> {
6 6
	const git = createGit(tmpdir());
7 7
	const versionString = await git.raw(["--version"]);
8 8
	const version = versionString

@@ -413,7 +413,7 @@
Loading
413 413
				files.map(async (file) => {
414 414
					let contents = await FS.readBuffer(file);
415 415
416 -
					const hasConflict = (c: string) => {
416 +
					const hasConflict = (c: string): boolean => {
417 417
						const regexes = [/^<{7}$/, /^={7}$/, /^>{7}$/];
418 418
419 419
						return !c

@@ -4,10 +4,10 @@
Loading
4 4
5 5
let pack: LanguagePack = {};
6 6
7 -
export async function initLocalization(lang?: string) {
8 -
	pack = await (async () => {
7 +
export async function initLocalization(lang?: string): Promise<void> {
8 +
	pack = await (async (): Promise<LanguagePack> => {
9 9
		try {
10 -
			const language: string = (() => {
10 +
			const language = ((): string => {
11 11
				if (lang) return lang;
12 12
13 13
				if (process.env.VSCODE_NLS_CONFIG) {

@@ -8,7 +8,7 @@
Loading
8 8
	let disposable: Disposable | undefined;
9 9
	let watcher: FSWatcher | undefined;
10 10
11 -
	export const init = (ignoredItems: string[]) => {
11 +
	export const init = (ignoredItems: string[]): void => {
12 12
		if (watcher) watcher.close();
13 13
14 14
		watcher = chokidar.watch([], {
@@ -16,7 +16,7 @@
Loading
16 16
		});
17 17
	};
18 18
19 -
	export const start = () => {
19 +
	export const start = (): void => {
20 20
		if (!watcher) return;
21 21
22 22
		stop();
@@ -35,7 +35,7 @@
Loading
35 35
		});
36 36
	};
37 37
38 -
	export const stop = () => {
38 +
	export const stop = (): void => {
39 39
		if (watcher) watcher.close();
40 40
41 41
		if (disposable) {
@@ -44,7 +44,7 @@
Loading
44 44
		}
45 45
	};
46 46
47 -
	const upload = async () => {
47 +
	const upload = async (): Promise<void> => {
48 48
		if (!window.state.focused) return;
49 49
50 50
		const cmds = await commands.getCommands();

@@ -2,7 +2,7 @@
Loading
2 2
import { CustomFiles, Factory, Profile, Settings, Watcher } from "~/services";
3 3
import state from "~/state";
4 4
5 -
export async function init() {
5 +
export async function init(): Promise<void> {
6 6
	const settings = await Settings.get();
7 7
8 8
	const syncer = Factory.generate(settings.syncer);

@@ -6,7 +6,10 @@
Loading
6 6
type Provider = "github" | "gitlab" | "bitbucket";
7 7
8 8
export namespace OAuth {
9 -
	export const listen = async (port: number, provider: Provider) => {
9 +
	export const listen = async (
10 +
		port: number,
11 +
		provider: Provider,
12 +
	): Promise<void> => {
10 13
		try {
11 14
			const app = express().use(
12 15
				express.json(),
@@ -58,7 +61,10 @@
Loading
58 61
		}
59 62
	};
60 63
61 -
	const getUser = async (token: string, provider: Provider) => {
64 +
	const getUser = async (
65 +
		token: string,
66 +
		provider: Provider,
67 +
	): Promise<string> => {
62 68
		try {
63 69
			const urls = {
64 70
				github: `https://api.github.com/user`,
@@ -78,19 +84,20 @@
Loading
78 84
79 85
			switch (provider) {
80 86
				case "github":
81 -
					return data.login as string;
87 +
					return data.login;
82 88
				case "gitlab":
83 89
				case "bitbucket":
84 -
					return data.username as string;
90 +
					return data.username;
85 91
				default:
86 -
					return;
92 +
					return "";
87 93
			}
88 94
		} catch (error) {
89 95
			Logger.error(error);
96 +
			return "";
90 97
		}
91 98
	};
92 99
93 -
	const getToken = async (code: string) => {
100 +
	const getToken = async (code: string): Promise<string> => {
94 101
		try {
95 102
			const data = await got
96 103
				.post(`https://github.com/login/oauth/access_token`, {
@@ -102,13 +109,17 @@
Loading
102 109
				})
103 110
				.text();
104 111
105 -
			return new URLSearchParams(data).get("access_token");
112 +
			return new URLSearchParams(data).get("access_token")!;
106 113
		} catch (error) {
107 114
			Logger.error(error);
115 +
			return "";
108 116
		}
109 117
	};
110 118
111 -
	const handleRequest = async (request: Request, provider: Provider) => {
119 +
	const handleRequest = async (
120 +
		request: Request,
121 +
		provider: Provider,
122 +
	): Promise<{ token?: string; user?: string } | undefined> => {
112 123
		if (provider !== "github") return;
113 124
114 125
		const token = await getToken(request.query.code as string);

@@ -15,7 +15,7 @@
Loading
15 15
			.then((result) => result && Webview.openErrorPage(err), error);
16 16
	};
17 17
18 -
	const debugMapper = (value: unknown) => {
18 +
	const debugMapper = (value: unknown): unknown => {
19 19
		return Array.isArray(value) ? JSON.stringify(value, undefined, 2) : value;
20 20
	};
21 21

@@ -18,7 +18,9 @@
Loading
18 18
		<T>(selector: (s: ISettings) => T): Promise<T>;
19 19
	};
20 20
21 -
	export const get: SettingsGet = async <T>(selector?: (s: ISettings) => T) => {
21 +
	export const get: SettingsGet = async <T>(
22 +
		selector?: (s: ISettings) => T,
23 +
	): Promise<T> => {
22 24
		const exists = await FS.exists(Environment.settings);
23 25
24 26
		if (!exists) {
@@ -48,7 +50,9 @@
Loading
48 50
		}
49 51
	};
50 52
51 -
	export const set = async (settings: DeepPartial<ISettings>) => {
53 +
	export const set = async (
54 +
		settings: DeepPartial<ISettings>,
55 +
	): Promise<void> => {
52 56
		const exists = await FS.exists(Environment.globalStoragePath);
53 57
		if (!exists) await FS.mkdir(Environment.globalStoragePath);
54 58
@@ -62,11 +66,11 @@
Loading
62 66
		await commands.executeCommand("syncify.reinitialize");
63 67
	};
64 68
65 -
	export const open = async () => {
69 +
	export const open = async (): Promise<void> => {
66 70
		Webview.openSettingsPage(await get());
67 71
	};
68 72
69 -
	export const openFile = async () => {
73 +
	export const openFile = async (): Promise<void> => {
70 74
		await window.showTextDocument(
71 75
			await workspace.openTextDocument(Environment.settings),
72 76
			ViewColumn.One,
@@ -74,7 +78,7 @@
Loading
74 78
		);
75 79
	};
76 80
77 -
	export const reset = async () => {
81 +
	export const reset = async (): Promise<void> => {
78 82
		const userIsSure = await confirm("settings -> reset");
79 83
80 84
		if (!userIsSure) return;

@@ -61,18 +61,18 @@
Loading
61 61
		);
62 62
	};
63 63
64 -
	export const get = () => {
64 +
	export const get = (): string[] => {
65 65
		return extensions.all
66 66
			.filter((ext) => !ext.packageJSON.isBuiltin)
67 67
			.map((ext) => ext.id);
68 68
	};
69 69
70 -
	export const getMissing = (downloadedExtensions: string[]) => {
70 +
	export const getMissing = (downloadedExtensions: string[]): string[] => {
71 71
		const installed = get();
72 72
		return downloadedExtensions.filter((ext) => !installed.includes(ext));
73 73
	};
74 74
75 -
	export const getUnneeded = (downloadedExtensions: string[]) => {
75 +
	export const getUnneeded = (downloadedExtensions: string[]): string[] => {
76 76
		return get().filter((ext) => !downloadedExtensions.includes(ext));
77 77
	};
78 78
}

@@ -1,3 +1,3 @@
Loading
1 -
export function stringifyPretty(object: any) {
1 +
export function stringifyPretty(object: any): string {
2 2
	return JSON.stringify(object, undefined, "\t");
3 3
}

@@ -9,7 +9,7 @@
Loading
9 9
	const openBtn = window.createStatusBarItem(1);
10 10
	const dismissBtn = window.createStatusBarItem(1);
11 11
12 -
	const dispose = () => {
12 +
	const dispose = (): void => {
13 13
		openDisposable.dispose();
14 14
		dismissDisposable.dispose();
15 15
		openBtn.dispose();

@@ -1,6 +1,6 @@
Loading
1 1
import { tmpdir } from "os";
2 2
import { resolve } from "path";
3 3
4 -
export function getCleanupPath(type: string) {
4 +
export function getCleanupPath(type: string): string {
5 5
	return resolve(tmpdir(), "vscode-syncify-tests", type);
6 6
}
Files Coverage
src 70.49%
Project Totals (32 files) 70.49%
1
coverage:
2
  range: 65..100
3

4
  status:
5
    project: off
6
    patch: off
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading