From e558071305ce215a7115b6f1c67e233f94d0dead Mon Sep 17 00:00:00 2001 From: David Sanders Date: Thu, 3 Oct 2024 11:08:48 -0700 Subject: [PATCH] chore: remove 'any' types (#169) --- src/24-hour-rule.ts | 18 +++++++++--------- src/api-review-state.ts | 4 ++-- src/enforce-semver-labels.ts | 2 +- src/utils/log-util.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/24-hour-rule.ts b/src/24-hour-rule.ts index ba7fd8e..fa5c9ad 100644 --- a/src/24-hour-rule.ts +++ b/src/24-hour-rule.ts @@ -31,7 +31,7 @@ type TimelineEvents = RestEndpointMethodTypes['issues']['listEventsForTimeline'] export const getMinimumOpenTime = (pr: PullRequest): number => { log('getMinimumOpenTime', LogLevel.INFO, `Fetching minimum open time for PR #${pr.number}.`); - const hasLabel = (label: string) => pr.labels.some((l: any) => l.name === label); + const hasLabel = (label: string) => pr.labels.some((l) => l.name === label); if (hasLabel(SEMVER_LABELS.MAJOR)) return MINIMUM_MAJOR_OPEN_TIME; if (hasLabel(SEMVER_LABELS.MINOR)) return MINIMUM_MINOR_OPEN_TIME; @@ -85,7 +85,7 @@ export const shouldPRHaveLabel = async ( const prefix = pr.title.split(':')[0]; const backportMatch = pr.title.match(/[bB]ackport/); const backportInTitle = backportMatch && backportMatch[0]; - const hasExcludedLabel = pr.labels.some((label: any) => EXCLUDE_LABELS.includes(label.name)); + const hasExcludedLabel = pr.labels.some((label) => EXCLUDE_LABELS.includes(label.name)); if ( EXCLUDE_PREFIXES.includes(prefix) || @@ -200,12 +200,12 @@ export async function setUp24HourRule(probot: Probot, disableCronForTesting = fa for (const repo of data.repositories) { probot.log(`Running 24 hour cron job on repo: ${repo.owner.login}/${repo.name}`); let page = 0; - const prs = []; + const prs: PullRequest[] = []; let lastPRCount = -1; do { lastPRCount = prs.length; prs.push( - ...( + ...(( await octokit.pulls.list({ owner: repo.owner.login, repo: repo.name, @@ -213,7 +213,7 @@ export async function setUp24HourRule(probot: Probot, disableCronForTesting = fa state: 'open', page, }) - ).data, + ).data as PullRequest[]), ); page++; } while (lastPRCount < prs.length); @@ -221,15 +221,15 @@ export async function setUp24HourRule(probot: Probot, disableCronForTesting = fa probot.log(`Found ${prs.length} prs for repo: ${repo.owner.login}/${repo.name}`); for (const pr of prs) { - const shouldLabel = await shouldPRHaveLabel(octokit, pr as any); + const shouldLabel = await shouldPRHaveLabel(octokit, pr); // Ensure that API review labels are updated after waiting period. if (!shouldLabel) { - const approvalState = await addOrUpdateAPIReviewCheck(octokit, pr as any); - await checkPRReadyForMerge(octokit, pr as any, approvalState); + const approvalState = await addOrUpdateAPIReviewCheck(octokit, pr); + await checkPRReadyForMerge(octokit, pr, approvalState); } - await applyLabelToPR(octokit, pr as any, shouldLabel); + await applyLabelToPR(octokit, pr, shouldLabel); } } } diff --git a/src/api-review-state.ts b/src/api-review-state.ts index 2a55ab7..7d113f4 100644 --- a/src/api-review-state.ts +++ b/src/api-review-state.ts @@ -45,8 +45,8 @@ export const isSemverMajorMinorLabel = (label: string) => export const getPRReadyDate = (pr: PullRequest) => { let readyTime = new Date(pr.created_at).getTime(); - if (!pr.labels.some((l: any) => l.name === API_SKIP_DELAY_LABEL)) { - const isMajorMinor = pr.labels.some((l: any) => isSemverMajorMinorLabel(l.name)); + if (!pr.labels.some((l) => l.name === API_SKIP_DELAY_LABEL)) { + const isMajorMinor = pr.labels.some((l) => isSemverMajorMinorLabel(l.name)); readyTime += isMajorMinor ? MINIMUM_MINOR_OPEN_TIME : MINIMUM_PATCH_OPEN_TIME; } diff --git a/src/enforce-semver-labels.ts b/src/enforce-semver-labels.ts index febfd41..bb3a9d3 100644 --- a/src/enforce-semver-labels.ts +++ b/src/enforce-semver-labels.ts @@ -23,7 +23,7 @@ export function setupSemverLabelEnforcement(probot: Probot) { log('setupSemverLabelEnforcement', LogLevel.INFO, `Checking #${pr.number} for semver label`); - const semverLabels = pr.labels.filter((l: any) => ALL_SEMVER_LABELS.includes(l.name)); + const semverLabels = pr.labels.filter((l) => ALL_SEMVER_LABELS.includes(l.name)); if (semverLabels.length === 0) { log('setupSemverLabelEnforcement', LogLevel.ERROR, `#${pr.number} is missing semver label`); diff --git a/src/utils/log-util.ts b/src/utils/log-util.ts index 7624847..169a93b 100644 --- a/src/utils/log-util.ts +++ b/src/utils/log-util.ts @@ -7,7 +7,7 @@ import { LogLevel } from '../enums'; * @param {LogLevel }logLevel - the severity level of the log * @param {any[]} message - the message to write to console */ -export const log = (functionName: string, logLevel: LogLevel, ...message: any[]) => { +export const log = (functionName: string, logLevel: LogLevel, ...message: unknown[]) => { const output = `${functionName}: ${message}`; if (logLevel === LogLevel.INFO) {