diff --git a/package.json b/package.json index 261e570..b0ea4d3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "description": "Electron's PR monitoring bot", - "main": "lib/index.js", + "main": "index.js", "scripts": { "build": "tsc", "lint": "prettier --list-different \"{src,spec}/**/*.ts\"", @@ -31,11 +31,12 @@ "lint-staged": "^15.2.10", "nock": "^14.0.10", "prettier": "^3.3.3", - "typescript": "^5.8.3", + "typescript": "^5.9.3", "vitest": "^3.0.5" }, "dependencies": { "@sentry/node": "^7.119.2", + "@tsconfig/node24": "^24.0.4", "probot": "^14.2.1", "semver": "^7.5.2" }, diff --git a/src/24-hour-rule.ts b/src/24-hour-rule.ts index e81a082..3500e02 100644 --- a/src/24-hour-rule.ts +++ b/src/24-hour-rule.ts @@ -153,7 +153,7 @@ export const labelShouldBeChecked = (label: Label) => { export async function setUp24HourRule(probot: Probot, disableCronForTesting = false) { probot.on( ['pull_request.opened', 'pull_request.unlabeled', 'pull_request.labeled'], - async (context: Context<'pull_request'>) => { + async (context) => { const { action, pull_request: pr, repository } = context.payload; // We only care about user labels adds for new-pr and semver labels. @@ -209,7 +209,7 @@ export async function setUp24HourRule(probot: Probot, disableCronForTesting = fa state: 'open', page, }) - ).data as PullRequest[]), + ).data as unknown as PullRequest[]), ); page++; } while (lastPRCount < prs.length); diff --git a/src/api-review-state.ts b/src/api-review-state.ts index 7623b7a..e98627b 100644 --- a/src/api-review-state.ts +++ b/src/api-review-state.ts @@ -405,32 +405,26 @@ export function setupAPIReviewStateManagement(probot: Probot) { * If a PR is opened or synchronized, we want to ensure the * API review check is up-to-date. */ - probot.on( - ['pull_request.synchronize', 'pull_request.opened'], - async (context: Context<'pull_request'>) => { - const pr = context.payload.pull_request as PullRequest; - await addOrUpdateAPIReviewCheck(context.octokit, pr); - }, - ); + probot.on(['pull_request.synchronize', 'pull_request.opened'], async (context) => { + const pr = context.payload.pull_request as PullRequest; + await addOrUpdateAPIReviewCheck(context.octokit, pr); + }); /** * If a PR review is submitted, we want to ensure the API * review check is up-to-date. */ - probot.on( - 'pull_request_review.submitted', - async (context: Context<'pull_request_review.submitted'>) => { - const pr = context.payload.pull_request as PullRequest; - const state = await addOrUpdateAPIReviewCheck(context.octokit, pr); - await checkPRReadyForMerge(context.octokit, pr, state); - }, - ); + probot.on('pull_request_review.submitted', async (context) => { + const pr = context.payload.pull_request as PullRequest; + const state = await addOrUpdateAPIReviewCheck(context.octokit, pr); + await checkPRReadyForMerge(context.octokit, pr, state); + }); /** * If a PR with API review requirements is marked ready for review, * we want to add the 'api-review/requested 🗳' label. */ - probot.on('pull_request.ready_for_review', async (context: Context<'pull_request'>) => { + probot.on('pull_request.ready_for_review', async (context) => { const { repository } = context.payload; const pr = context.payload.pull_request as PullRequest; @@ -454,7 +448,7 @@ export function setupAPIReviewStateManagement(probot: Probot) { * If a PR with existing API review requirements is converted to draft status, * we want to remove the 'api-review/requested 🗳' label. */ - probot.on('pull_request.converted_to_draft', async (context: Context<'pull_request'>) => { + probot.on('pull_request.converted_to_draft', async (context) => { const { repository } = context.payload; const pr = context.payload.pull_request as PullRequest; @@ -490,7 +484,7 @@ export function setupAPIReviewStateManagement(probot: Probot) { * - If any api-review-{state} label besides api-review-requested is added, remove it. * API approval is controlled solely by cation. */ - probot.on('pull_request.labeled', async (context: Context<'pull_request.labeled'>) => { + probot.on('pull_request.labeled', async (context) => { const { label, repository, @@ -568,7 +562,7 @@ export function setupAPIReviewStateManagement(probot: Probot) { * label. * */ - probot.on('pull_request.unlabeled', async (context: Context<'pull_request.unlabeled'>) => { + probot.on('pull_request.unlabeled', async (context) => { const { label, sender: { login: initiator }, diff --git a/src/deprecation-review-state.ts b/src/deprecation-review-state.ts index d1b0a1b..6dfa372 100644 --- a/src/deprecation-review-state.ts +++ b/src/deprecation-review-state.ts @@ -187,19 +187,16 @@ export async function maybeAddChecklistComment(octokit: ProbotOctokit, pr: PullR } export function setupDeprecationReviewStateManagement(probot: Probot) { - probot.on( - ['pull_request.synchronize', 'pull_request.opened'], - async (context: Context<'pull_request'>) => { - const pr = context.payload.pull_request as PullRequest; - await addOrUpdateDeprecationReviewCheck(context.octokit, pr); - }, - ); + probot.on(['pull_request.synchronize', 'pull_request.opened'], async (context) => { + const pr = context.payload.pull_request as PullRequest; + await addOrUpdateDeprecationReviewCheck(context.octokit, pr); + }); /** * The deprecation-review/requested label initiates deprecation review, * but the deprecation-review/complete label is solely controlled by cation */ - probot.on('pull_request.labeled', async (context: Context<'pull_request.labeled'>) => { + probot.on('pull_request.labeled', async (context) => { const { label, sender: { login: initiator }, @@ -242,7 +239,7 @@ export function setupDeprecationReviewStateManagement(probot: Probot) { * did not remove a deprecation-review state label other than * deprecation-review-requested. */ - probot.on('pull_request.unlabeled', async (context: Context<'pull_request.unlabeled'>) => { + probot.on('pull_request.unlabeled', async (context) => { const { label, sender: { login: initiator }, @@ -285,7 +282,7 @@ export function setupDeprecationReviewStateManagement(probot: Probot) { } }); - probot.on('issue_comment.edited', async (context: Context<'issue_comment.edited'>) => { + probot.on('issue_comment.edited', async (context) => { const { comment, issue: { labels, number: prNumber, pull_request: pr }, diff --git a/src/enforce-semver-labels.ts b/src/enforce-semver-labels.ts index a593a73..a764ae7 100644 --- a/src/enforce-semver-labels.ts +++ b/src/enforce-semver-labels.ts @@ -18,7 +18,7 @@ export function setupSemverLabelEnforcement(probot: Probot) { 'pull_request.labeled', 'pull_request.synchronize', ], - async (context: Context<'pull_request'>) => { + async (context) => { const { pull_request: pr } = context.payload; log('setupSemverLabelEnforcement', LogLevel.INFO, `Checking #${pr.number} for semver label`); diff --git a/tsconfig.json b/tsconfig.json index ba63a7f..b0489fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,15 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es2024", - "outDir": "lib", - "sourceMap": true, - "rootDir": "src", - "experimentalDecorators": true, - "allowJs": true, - "strict": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true - }, - "exclude": [ - "node_modules", - "spec", - "lib", - "coverage", - "vitest.config.ts" - ] + "extends": "@tsconfig/node24/tsconfig.json", + "compilerOptions": { + "sourceMap": true, + "strict": false, + "outDir": "lib", + "types": [ + "node" + ], + "declaration": true + }, + "include": [ + "src" + ] } diff --git a/yarn.lock b/yarn.lock index 465e541..cc4b1db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -903,6 +903,13 @@ __metadata: languageName: node linkType: hard +"@tsconfig/node24@npm:^24.0.4": + version: 24.0.4 + resolution: "@tsconfig/node24@npm:24.0.4" + checksum: 10c0/9c5d4173204c6935c45d3ff0584fd423bd7d8bc3f6b246e646320ae584e4226b34ea1c66ec67cd16769c73e7e80f4cc562287b0acaa4ec81aa482463972ff83f + languageName: node + linkType: hard + "@types/chai@npm:^5.2.2": version: 5.2.3 resolution: "@types/chai@npm:5.2.3" @@ -1219,6 +1226,7 @@ __metadata: resolution: "cation@workspace:." dependencies: "@sentry/node": "npm:^7.119.2" + "@tsconfig/node24": "npm:^24.0.4" "@types/ioredis": "npm:^4.28.10" "@types/node": "npm:^22.9.0" "@vitest/coverage-v8": "npm:^3.0.5" @@ -1228,7 +1236,7 @@ __metadata: prettier: "npm:^3.3.3" probot: "npm:^14.2.1" semver: "npm:^7.5.2" - typescript: "npm:^5.8.3" + typescript: "npm:^5.9.3" vitest: "npm:^3.0.5" languageName: unknown linkType: soft @@ -3131,7 +3139,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.8.3": +"typescript@npm:^5.9.3": version: 5.9.3 resolution: "typescript@npm:5.9.3" bin: @@ -3141,7 +3149,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^5.8.3#optional!builtin": +"typescript@patch:typescript@npm%3A^5.9.3#optional!builtin": version: 5.9.3 resolution: "typescript@patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5" bin: