Skip to content

Commit 7daacb3

Browse files
committed
Fix linting and typing errors
1 parent 4c92b8a commit 7daacb3

File tree

7 files changed

+1508
-528
lines changed

7 files changed

+1508
-528
lines changed

build-filtered-data.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { writeFileSync } from 'fs'
22
import { json2csv } from 'json-2-csv'
3-
import { RequestError } from 'octokit'
3+
import { RequestError } from '@octokit/request-error'
44

55
import denyList from './helpers/data/deny-list.json' with { type: 'json' }
66
import governmentServiceOwners from './helpers/data/service-owners.json' with { type: 'json' }
@@ -10,6 +10,10 @@ import { Result } from './helpers/result.mjs'
1010

1111
import rawDeps from './data/raw-deps.json' with { type: 'json' }
1212

13+
/**
14+
* Analyses all public dependent repos
15+
*
16+
*/
1317
async function filterDeps () {
1418
const builtData = []
1519
const processedIndexes = []
@@ -48,6 +52,11 @@ async function filterDeps () {
4852
console.log("We're done!")
4953
}
5054

55+
/**
56+
* Analyses a repo
57+
* @param {object} repo - the repo to analyse
58+
* @returns {Promise<object>} - the result of the analysis
59+
*/
5160
export async function analyseRepo (repo) {
5261
const repoOwner = repo.owner
5362
const repoName = repo.repo_name
@@ -94,6 +103,11 @@ export async function analyseRepo (repo) {
94103
return result.getResult(repoData)
95104
}
96105

106+
/**
107+
* Writes the data to files
108+
* @param {Array} builtData - the analysed repo data
109+
* @param {Array} processedIndexes - indexes of repos which have been processed
110+
*/
97111
function writeToFiles (builtData, processedIndexes) {
98112
// Write JSON file
99113
const jsonData = JSON.stringify(builtData, null, 2)

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
22
import babelParser from '@babel/eslint-parser'
3-
import jsdoc from 'eslint-plugin-jsdoc';
3+
import jsdoc from 'eslint-plugin-jsdoc'
44

55
/** @type {import('eslint').Linter.Config[]} */
66
export default [

helpers/octokit.mjs

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ const graphQLAuth = graphql.defaults({
5151
* actually count against the GraphQL rate limit.
5252
*
5353
* This contrasts with the REST API which would require 2 requests to get the same information:
54-
* 1. Get the repo-level info like created_at and updated_at
55-
* 2. Get the latest commit SHA
54+
* 1. Get the repo-level info like created_at and updated_at
55+
* 2. Get the latest commit SHA
5656
*
5757
* In testing, this query sped up the build script from 80 minutes to 60 minutes.
5858
*
@@ -61,25 +61,24 @@ const graphQLAuth = graphql.defaults({
6161
*
6262
* Repo info is returned in the format:
6363
* {
64-
* repository: {
65-
* createdAt: '2022-01-01T00:00:00Z',
66-
* updatedAt: '2023-01-01T00:00:00Z',
67-
* defaultBranchRef: {
68-
* target: {
69-
* oid: 'sha-123'
70-
* }
71-
* }
72-
* },
73-
* rateLimit: {
74-
* cost: 1,
75-
* remaining: 5000,
76-
* resetAt: '2023-01-01T00:00:00Z'
77-
* }
64+
* repository: {
65+
* createdAt: '2022-01-01T00:00:00Z',
66+
* updatedAt: '2023-01-01T00:00:00Z',
67+
* defaultBranchRef: {
68+
* target: {
69+
* oid: 'sha-123'
70+
* }
71+
* }
72+
* },
73+
* rateLimit: {
74+
* cost: 1,
75+
* remaining: 5000,
76+
* resetAt: '2023-01-01T00:00:00Z'
77+
* }
7878
* }
79-
*
8079
* @param {string} owner - the repo owners
8180
* @param {string} name - the repo name
82-
* @returns {Promise<import('@octokit/graphql').GraphQlQueryResponse>} - the repo info
81+
* @returns {Promise<import('@octokit/graphql').GraphQlQueryResponseData>} - the repo info
8382
*/
8483
export async function getRepo (owner, name) {
8584
const query = `
@@ -113,12 +112,10 @@ export async function getRepo (owner, name) {
113112

114113
/**
115114
* Gets the tree for a repo with a given sha
116-
*
117115
* @param {string} repoOwner - The owner of the repo
118116
* @param {string} repoName - The name of the repo
119117
* @param {string} treeSha - The sha of the tree
120-
* @returns {Promise<import('@octokit/rest').Response<import('@octokit/rest').GitGetTreeResponse>>}
121-
* @throws {RequestError} - If the request fails
118+
* @returns {Promise<import('@octokit/rest').RestEndpointMethodTypes['git']['getTree']['response']>} - the response
122119
*/
123120
export async function getTree (repoOwner, repoName, treeSha) {
124121
return await octokit.rest.git.getTree({
@@ -131,12 +128,10 @@ export async function getTree (repoOwner, repoName, treeSha) {
131128

132129
/**
133130
* Gets the contents of a file in a repo
134-
*
135131
* @param {string} repoOwner - The owner of the repo
136132
* @param {string} repoName - The name of the repo
137133
* @param {string} filePath - The path to the file
138-
* @returns {Promise<import('@octokit/rest').Response<import('@octokit/rest').ReposGetContentResponse>>} - the file content
139-
* @throws {RequestError} - If the request fails
134+
* @returns {Promise<import('@octokit/rest').RestEndpointMethodTypes['repos']['getContent']['response']>} - the file content
140135
*/
141136
export async function getFileContent (repoOwner, repoName, filePath) {
142137
return await octokit.rest.repos.getContent({
@@ -149,9 +144,7 @@ export async function getFileContent (repoOwner, repoName, filePath) {
149144

150145
/**
151146
* Check rate limit
152-
*
153-
* @returns {number} - The number of remaining requests
154-
* @throws {RequestError} - If the request fails
147+
* @returns {Promise<number>} - The number of remaining requests
155148
*/
156149
export async function getRemainingRateLimit () {
157150
const rateLimit = await octokit.rest.rateLimit.get()

0 commit comments

Comments
 (0)