Skip to content

Commit 43a2263

Browse files
authored
chore(front): add JSDoc types for scorecard.js (#699) (#745)
* enhance type safety for websocket.js * correction for linter * revert automatic prettier modifications * enhance type safety for websocket.js * correction for linter * Enhance type safety for file public/common/scorecard.js * add missing type for data. Create a ScorecardData typeDef event only score.data is used at the moment. * chore: align websocket.js with master
1 parent 6f14360 commit 43a2263

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

public/common/scorecard.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,56 @@
11
// Import Third-party Dependencies
22
import { getJSON } from "@nodesecure/vis-network";
33

4+
/**
5+
* @typedef {Object} ScorecardCheckDocumentation
6+
* @property {string} short
7+
* @property {string} url
8+
*/
9+
10+
/**
11+
* @typedef {Object} ScorecardCheck
12+
* @property {string} name
13+
* @property {number} score
14+
* @property {string} reason
15+
* @property {string[] | null} details
16+
* @property {ScorecardCheckDocumentation} documentation
17+
*/
18+
19+
/**
20+
* @typedef {Object} ScorecardRepo
21+
* @property {string} name
22+
* @property {string} commit
23+
*/
24+
25+
/**
26+
* @typedef {Object} ScorecardTool
27+
* @property {string} version
28+
* @property {string} commit
29+
*/
30+
31+
/**
32+
* @typedef {Object} ScorecardData
33+
* @property {string} date
34+
* @property {ScorecardRepo} repo
35+
* @property {ScorecardTool} scorecard
36+
* @property {number} score
37+
* @property {ScorecardCheck[]} checks
38+
*/
39+
440
/**
541
* @param {!string} repoName
42+
* @param {string} platform
43+
* @returns {Promise<ScorecardData | null>}
644
*/
745
export async function fetchScorecardData(repoName, platform = "github.com") {
846
try {
9-
const { data } = (await getJSON(`/scorecard/${repoName}?platform=${platform}`));
47+
/** @type any responseRaw */
48+
const responseRaw = (await getJSON(`/scorecard/${repoName}?platform=${platform}`));
49+
50+
/** @type {{ data: ScorecardData }} */
51+
const response = responseRaw;
52+
53+
const data = response.data;
1054
if (!data) {
1155
return null;
1256
}
@@ -20,6 +64,11 @@ export async function fetchScorecardData(repoName, platform = "github.com") {
2064
}
2165
}
2266

67+
/**
68+
* @param {string} repoName
69+
* @param {string} platform
70+
* @returns {string}
71+
*/
2372
export function getScorecardLink(
2473
repoName,
2574
platform

0 commit comments

Comments
 (0)