Skip to content

Commit

Permalink
Refactor to use @imports
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 24, 2024
1 parent 8a3542e commit 3374383
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 40 deletions.
7 changes: 3 additions & 4 deletions lib/collective/configure.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @typedef {import('../util/types.js').Context} Context
* @typedef {import('../util/types.js').GraphQl} GraphQl
* @typedef {import('@octokit/graphql').GraphqlResponseError<unknown>} GraphqlResponseError
* @import {graphql as GraphQl, GraphqlResponseError} from '@octokit/graphql'
* @import {Context} from '../util/types.js'
*/

import {graphql} from '@octokit/graphql'
Expand Down Expand Up @@ -59,7 +58,7 @@ function wrap(action) {
* @returns
*/
function retry(error) {
const exception = /** @type {GraphqlResponseError} */ (error)
const exception = /** @type {GraphqlResponseError<unknown>} */ (error)
console.log('wrap err:', exception)
console.log('to do:', 'does `status` really not exist?')
const after =
Expand Down
7 changes: 3 additions & 4 deletions lib/collective/labels.js
Original file line number Diff line number Diff line change
@@ -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'
*/

/**
Expand Down Expand Up @@ -103,7 +102,7 @@ export async function labels(context) {
*/
function addAll(group) {
const {labels, color} = group
/** @type {import('d3-scale').ScaleLinear<number, string, unknown> | undefined} */
/** @type {ScaleLinear<number, string, unknown> | undefined} */
let scale

if (typeof color !== 'string' && color.from && color.to) {
Expand Down
2 changes: 1 addition & 1 deletion lib/collective/orgs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('../util/types.js').Context} Context
* @import {Context} from '../util/types.js'
*/

import {promisify} from 'node:util'
Expand Down
2 changes: 1 addition & 1 deletion lib/org/people.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('../util/types.js').Context} Context
* @import {Context} from '../util/types.js'
*/

import chalk from 'chalk'
Expand Down
3 changes: 1 addition & 2 deletions lib/org/repos.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/org/teams.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('../util/types.js').Context} Context
* @import {Context} from '../util/types.js'
*/

import {promisify} from 'node:util'
Expand Down
3 changes: 1 addition & 2 deletions lib/repo/collaborators.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions lib/repo/labels.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions lib/team/create.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions lib/team/members.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions lib/team/repo.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions lib/team/request.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 1 addition & 3 deletions lib/team/update.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 1 addition & 2 deletions lib/util/find.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 5 additions & 5 deletions lib/util/types.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @typedef {import('@octokit/graphql').graphql} GraphQl
* @typedef {import('@octokit/plugin-paginate-rest').PaginateInterface} Paginate
* @typedef {import('@octokit/types').RequestInterface<object>} Request
* @import {graphql as GraphQl} from '@octokit/graphql'
* @import {PaginateInterface} from '@octokit/plugin-paginate-rest'
* @import {RequestInterface} from '@octokit/types'
*/

/**
Expand All @@ -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.
Expand Down

0 comments on commit 3374383

Please sign in to comment.