From 4be9281fef2dd288ae126e8c9b8dd4ce74c438ce Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Tue, 7 Apr 2026 09:26:56 +0200 Subject: [PATCH 1/8] enhance type safety for websocket.js --- public/websocket.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/public/websocket.js b/public/websocket.js index 195aef07..beffcb2f 100644 --- a/public/websocket.js +++ b/public/websocket.js @@ -18,8 +18,10 @@ export class WebSocketClient extends EventTarget { * @type {{ search: (spec: Spec) => void, remove: (spec: Spec) => void }} */ this.commands = { - search: (spec) => this.send({ commandName: "SEARCH", spec }), - remove: (spec) => this.send({ commandName: "REMOVE", spec }) + search: /** @param {Spec} spec */ (spec) => + this.send({ commandName: "SEARCH", spec }), + remove: /** @param {Spec} spec */ (spec) => + this.send({ commandName: "REMOVE", spec }), }; window.socket = this; @@ -40,18 +42,13 @@ export class WebSocketClient extends EventTarget { /** @type {{ status: string, [key: string]: any }} */ const data = JSON.parse(event.data); if (!data.status) { - console.warn( - "[WEBSOCKET] Received data without status:", - data - ); + console.warn("[WEBSOCKET] Received data without status:", data); return; } console.log(`[WEBSOCKET] data status = '${data.status}'`); - this.dispatchEvent( - new CustomEvent(data.status, { detail: data }) - ); + this.dispatchEvent(new CustomEvent(data.status, { detail: data })); } close() { From 26369696d0e15f20cdf520e7a991d012230b5ffe Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Tue, 7 Apr 2026 23:52:20 +0200 Subject: [PATCH 2/8] correction for linter --- public/websocket.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/websocket.js b/public/websocket.js index beffcb2f..b65f4475 100644 --- a/public/websocket.js +++ b/public/websocket.js @@ -18,10 +18,8 @@ export class WebSocketClient extends EventTarget { * @type {{ search: (spec: Spec) => void, remove: (spec: Spec) => void }} */ this.commands = { - search: /** @param {Spec} spec */ (spec) => - this.send({ commandName: "SEARCH", spec }), - remove: /** @param {Spec} spec */ (spec) => - this.send({ commandName: "REMOVE", spec }), + search: (spec) => this.send({ commandName: "SEARCH", spec }), + remove: (spec) => this.send({ commandName: "REMOVE", spec }) }; window.socket = this; From 1825a040276ef5fbcadefbc4e0f8a5a193b35ae6 Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Thu, 9 Apr 2026 08:02:56 +0200 Subject: [PATCH 3/8] revert automatic prettier modifications --- public/websocket.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/websocket.js b/public/websocket.js index b65f4475..195aef07 100644 --- a/public/websocket.js +++ b/public/websocket.js @@ -40,13 +40,18 @@ export class WebSocketClient extends EventTarget { /** @type {{ status: string, [key: string]: any }} */ const data = JSON.parse(event.data); if (!data.status) { - console.warn("[WEBSOCKET] Received data without status:", data); + console.warn( + "[WEBSOCKET] Received data without status:", + data + ); return; } console.log(`[WEBSOCKET] data status = '${data.status}'`); - this.dispatchEvent(new CustomEvent(data.status, { detail: data })); + this.dispatchEvent( + new CustomEvent(data.status, { detail: data }) + ); } close() { From 4ad6e49b120d335df56bcc40e7f47365b849a625 Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Tue, 7 Apr 2026 09:26:56 +0200 Subject: [PATCH 4/8] enhance type safety for websocket.js --- public/websocket.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/public/websocket.js b/public/websocket.js index 195aef07..beffcb2f 100644 --- a/public/websocket.js +++ b/public/websocket.js @@ -18,8 +18,10 @@ export class WebSocketClient extends EventTarget { * @type {{ search: (spec: Spec) => void, remove: (spec: Spec) => void }} */ this.commands = { - search: (spec) => this.send({ commandName: "SEARCH", spec }), - remove: (spec) => this.send({ commandName: "REMOVE", spec }) + search: /** @param {Spec} spec */ (spec) => + this.send({ commandName: "SEARCH", spec }), + remove: /** @param {Spec} spec */ (spec) => + this.send({ commandName: "REMOVE", spec }), }; window.socket = this; @@ -40,18 +42,13 @@ export class WebSocketClient extends EventTarget { /** @type {{ status: string, [key: string]: any }} */ const data = JSON.parse(event.data); if (!data.status) { - console.warn( - "[WEBSOCKET] Received data without status:", - data - ); + console.warn("[WEBSOCKET] Received data without status:", data); return; } console.log(`[WEBSOCKET] data status = '${data.status}'`); - this.dispatchEvent( - new CustomEvent(data.status, { detail: data }) - ); + this.dispatchEvent(new CustomEvent(data.status, { detail: data })); } close() { From 6cb6ffda77047a8492280440d5584b398086e878 Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Tue, 7 Apr 2026 23:52:20 +0200 Subject: [PATCH 5/8] correction for linter --- public/websocket.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/websocket.js b/public/websocket.js index beffcb2f..b65f4475 100644 --- a/public/websocket.js +++ b/public/websocket.js @@ -18,10 +18,8 @@ export class WebSocketClient extends EventTarget { * @type {{ search: (spec: Spec) => void, remove: (spec: Spec) => void }} */ this.commands = { - search: /** @param {Spec} spec */ (spec) => - this.send({ commandName: "SEARCH", spec }), - remove: /** @param {Spec} spec */ (spec) => - this.send({ commandName: "REMOVE", spec }), + search: (spec) => this.send({ commandName: "SEARCH", spec }), + remove: (spec) => this.send({ commandName: "REMOVE", spec }) }; window.socket = this; From d5eab9aa55477bcbf36356c60f1d078585cc0e59 Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Wed, 8 Apr 2026 00:19:27 +0200 Subject: [PATCH 6/8] Enhance type safety for file public/common/scorecard.js --- public/common/scorecard.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/common/scorecard.js b/public/common/scorecard.js index 51e405f1..216287ff 100644 --- a/public/common/scorecard.js +++ b/public/common/scorecard.js @@ -20,6 +20,11 @@ export async function fetchScorecardData(repoName, platform = "github.com") { } } +/** + * @param {string} repoName + * @param {string} platform + * @returns {string} + */ export function getScorecardLink( repoName, platform From 71798e153758946d83d02a463cfdf4f1b5d9d9a3 Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Thu, 9 Apr 2026 23:54:44 +0200 Subject: [PATCH 7/8] add missing type for data. Create a ScorecardData typeDef event only score.data is used at the moment. --- public/common/scorecard.js | 46 +++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/public/common/scorecard.js b/public/common/scorecard.js index 216287ff..30cee964 100644 --- a/public/common/scorecard.js +++ b/public/common/scorecard.js @@ -1,12 +1,56 @@ // Import Third-party Dependencies import { getJSON } from "@nodesecure/vis-network"; +/** + * @typedef {Object} ScorecardCheckDocumentation + * @property {string} short + * @property {string} url + */ + +/** + * @typedef {Object} ScorecardCheck + * @property {string} name + * @property {number} score + * @property {string} reason + * @property {string[] | null} details + * @property {ScorecardCheckDocumentation} documentation + */ + +/** + * @typedef {Object} ScorecardRepo + * @property {string} name + * @property {string} commit + */ + +/** + * @typedef {Object} ScorecardTool + * @property {string} version + * @property {string} commit + */ + +/** + * @typedef {Object} ScorecardData + * @property {string} date + * @property {ScorecardRepo} repo + * @property {ScorecardTool} scorecard + * @property {number} score + * @property {ScorecardCheck[]} checks + */ + /** * @param {!string} repoName + * @param {string} platform + * @returns {Promise} */ export async function fetchScorecardData(repoName, platform = "github.com") { try { - const { data } = (await getJSON(`/scorecard/${repoName}?platform=${platform}`)); + /** @type any responseRaw */ + const responseRaw = (await getJSON(`/scorecard/${repoName}?platform=${platform}`)); + + /** @type {{ data: ScorecardData }} */ + const response = responseRaw; + + const data = response.data; if (!data) { return null; } From 3275be40d103f870bfb39610bc94d2212e037ad4 Mon Sep 17 00:00:00 2001 From: ZeEarth Date: Fri, 10 Apr 2026 00:14:34 +0200 Subject: [PATCH 8/8] chore: align websocket.js with master --- public/websocket.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/websocket.js b/public/websocket.js index b65f4475..195aef07 100644 --- a/public/websocket.js +++ b/public/websocket.js @@ -40,13 +40,18 @@ export class WebSocketClient extends EventTarget { /** @type {{ status: string, [key: string]: any }} */ const data = JSON.parse(event.data); if (!data.status) { - console.warn("[WEBSOCKET] Received data without status:", data); + console.warn( + "[WEBSOCKET] Received data without status:", + data + ); return; } console.log(`[WEBSOCKET] data status = '${data.status}'`); - this.dispatchEvent(new CustomEvent(data.status, { detail: data })); + this.dispatchEvent( + new CustomEvent(data.status, { detail: data }) + ); } close() {