From 3374383241c833172e338899aba8c5e07ee1595d Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 24 Sep 2024 14:39:18 +0200 Subject: [PATCH] Refactor to use `@import`s --- lib/collective/configure.js | 7 +++---- lib/collective/labels.js | 7 +++---- lib/collective/orgs.js | 2 +- lib/org/people.js | 2 +- lib/org/repos.js | 3 +-- lib/org/teams.js | 2 +- lib/repo/collaborators.js | 3 +-- lib/repo/labels.js | 4 +--- lib/team/create.js | 4 +--- lib/team/members.js | 4 +--- lib/team/repo.js | 4 +--- lib/team/request.js | 4 +--- lib/team/update.js | 4 +--- lib/util/find.js | 3 +-- lib/util/types.js | 10 +++++----- 15 files changed, 23 insertions(+), 40 deletions(-) diff --git a/lib/collective/configure.js b/lib/collective/configure.js index 0e3bb1c..c18ffed 100644 --- a/lib/collective/configure.js +++ b/lib/collective/configure.js @@ -1,7 +1,6 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').GraphQl} GraphQl - * @typedef {import('@octokit/graphql').GraphqlResponseError} GraphqlResponseError + * @import {graphql as GraphQl, GraphqlResponseError} from '@octokit/graphql' + * @import {Context} from '../util/types.js' */ import {graphql} from '@octokit/graphql' @@ -59,7 +58,7 @@ function wrap(action) { * @returns */ function retry(error) { - const exception = /** @type {GraphqlResponseError} */ (error) + const exception = /** @type {GraphqlResponseError} */ (error) console.log('wrap err:', exception) console.log('to do:', 'does `status` really not exist?') const after = diff --git a/lib/collective/labels.js b/lib/collective/labels.js index 806245d..e5e9571 100644 --- a/lib/collective/labels.js +++ b/lib/collective/labels.js @@ -1,7 +1,6 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').Label} Label - * @typedef {import('../util/types.js').Labels} Labels + * @import {ScaleLinear} from 'd3-scale' + * @import {Context, Labels, Label} from '../util/types.js' */ /** @@ -103,7 +102,7 @@ export async function labels(context) { */ function addAll(group) { const {labels, color} = group - /** @type {import('d3-scale').ScaleLinear | undefined} */ + /** @type {ScaleLinear | undefined} */ let scale if (typeof color !== 'string' && color.from && color.to) { diff --git a/lib/collective/orgs.js b/lib/collective/orgs.js index d893f60..f7acf46 100644 --- a/lib/collective/orgs.js +++ b/lib/collective/orgs.js @@ -1,5 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context + * @import {Context} from '../util/types.js' */ import {promisify} from 'node:util' diff --git a/lib/org/people.js b/lib/org/people.js index 933af2a..921f2b0 100644 --- a/lib/org/people.js +++ b/lib/org/people.js @@ -1,5 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context + * @import {Context} from '../util/types.js' */ import chalk from 'chalk' diff --git a/lib/org/repos.js b/lib/org/repos.js index 15f7f8c..2a68351 100644 --- a/lib/org/repos.js +++ b/lib/org/repos.js @@ -1,6 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').Repo} Repo + * @import {Context, Repo} from '../util/types.js' */ import {promisify} from 'node:util' diff --git a/lib/org/teams.js b/lib/org/teams.js index b38eef3..c5b56e6 100644 --- a/lib/org/teams.js +++ b/lib/org/teams.js @@ -1,5 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context + * @import {Context} from '../util/types.js' */ import {promisify} from 'node:util' diff --git a/lib/repo/collaborators.js b/lib/repo/collaborators.js index 2b70e50..7e9a90b 100644 --- a/lib/repo/collaborators.js +++ b/lib/repo/collaborators.js @@ -1,6 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').Repo} Repo + * @import {Context, Repo} from '../util/types.js' */ import chalk from 'chalk' diff --git a/lib/repo/labels.js b/lib/repo/labels.js index 63add69..57ae2db 100644 --- a/lib/repo/labels.js +++ b/lib/repo/labels.js @@ -1,7 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').Label} Label - * @typedef {import('../util/types.js').Repo} Repo + * @import {Context, Label, Repo} from '../util/types.js' */ import assert from 'node:assert/strict' diff --git a/lib/team/create.js b/lib/team/create.js index 616f632..3b30d4b 100644 --- a/lib/team/create.js +++ b/lib/team/create.js @@ -1,7 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').GithubTeam} GithubTeam - * @typedef {import('../util/types.js').TeamInfo} TeamInfo + * @import {Context, GithubTeam, TeamInfo} from '../util/types.js' */ import chalk from 'chalk' diff --git a/lib/team/members.js b/lib/team/members.js index 70014d9..fcaf00b 100644 --- a/lib/team/members.js +++ b/lib/team/members.js @@ -1,7 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').GithubTeam} GithubTeam - * @typedef {import('../util/types.js').TeamInfo} TeamInfo + * @import {Context, GithubTeam, TeamInfo} from '../util/types.js' */ import difference from 'arr-diff' diff --git a/lib/team/repo.js b/lib/team/repo.js index 9f96350..89f0206 100644 --- a/lib/team/repo.js +++ b/lib/team/repo.js @@ -1,7 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').GithubTeam} GithubTeam - * @typedef {import('../util/types.js').TeamInfo} TeamInfo + * @import {Context, GithubTeam, TeamInfo} from '../util/types.js' */ import assert from 'node:assert/strict' diff --git a/lib/team/request.js b/lib/team/request.js index bf3ac47..219b0f8 100644 --- a/lib/team/request.js +++ b/lib/team/request.js @@ -1,7 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').GithubTeam} GithubTeam - * @typedef {import('../util/types.js').TeamInfo} TeamInfo + * @import {Context, GithubTeam, TeamInfo} from '../util/types.js' */ // Request a team. diff --git a/lib/team/update.js b/lib/team/update.js index 69a72e5..012a7c2 100644 --- a/lib/team/update.js +++ b/lib/team/update.js @@ -1,7 +1,5 @@ /** - * @typedef {import('../util/types.js').Context} Context - * @typedef {import('../util/types.js').GithubTeam} GithubTeam - * @typedef {import('../util/types.js').TeamInfo} TeamInfo + * @import {Context, GithubTeam, TeamInfo} from '../util/types.js' */ import chalk from 'chalk' diff --git a/lib/util/find.js b/lib/util/find.js index 6d399a7..643c2b3 100644 --- a/lib/util/find.js +++ b/lib/util/find.js @@ -1,6 +1,5 @@ /** - * @typedef {import('./types.js').Context} Context - * @typedef {import('./types.js').Role} Role + * @import {Context, Role} from './types.js' */ import assert from 'node:assert/strict' diff --git a/lib/util/types.js b/lib/util/types.js index 099c158..2428e53 100644 --- a/lib/util/types.js +++ b/lib/util/types.js @@ -1,7 +1,7 @@ /** - * @typedef {import('@octokit/graphql').graphql} GraphQl - * @typedef {import('@octokit/plugin-paginate-rest').PaginateInterface} Paginate - * @typedef {import('@octokit/types').RequestInterface} Request + * @import {graphql as GraphQl} from '@octokit/graphql' + * @import {PaginateInterface} from '@octokit/plugin-paginate-rest' + * @import {RequestInterface} from '@octokit/types' */ /** @@ -19,9 +19,9 @@ * Name of the collective (example: `unified`). * @property {GraphQl} ghQuery * Send a request to the GitHub GQL API. - * @property {Request} ghRequest + * @property {RequestInterface} ghRequest * Send a request to the GitHub REST API. - * @property {Paginate} ghPaginate + * @property {PaginateInterface} ghPaginate * Send a paginate request to the GitHub REST API. * @property {string} ghToken * GH token.