Skip to content

Commit

Permalink
chore: remove 'any' types (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 authored Oct 3, 2024
1 parent bb2bb6e commit e558071
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/24-hour-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) ||
Expand Down Expand Up @@ -200,36 +200,36 @@ 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,
per_page: 100,
state: 'open',
page,
})
).data,
).data as PullRequest[]),
);
page++;
} while (lastPRCount < prs.length);

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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/api-review-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/enforce-semver-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/log-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e558071

Please sign in to comment.