зеркало из https://github.com/electron/trop.git
build: switch to ESLint from TSLint (#261)
This commit is contained in:
Родитель
cfbef6afc4
Коммит
d03bcb88d4
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"env": {
|
||||
"es2021": true
|
||||
},
|
||||
"extends": "standard-with-typescript",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {}
|
||||
}
|
10
package.json
10
package.json
|
@ -33,6 +33,12 @@
|
|||
"@types/node-fetch": "^2.5.4",
|
||||
"@types/pino-std-serializers": "^4.0.0",
|
||||
"@types/sinon": "^10.0.15",
|
||||
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-standard-with-typescript": "^36.0.0",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-n": "^15.0.0",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"husky": "^6.0.0",
|
||||
"jest": "^29.0.0",
|
||||
"lint-staged": "^10.4.2",
|
||||
|
@ -41,9 +47,7 @@
|
|||
"sinon": "^15.2.0",
|
||||
"smee-client": "^1.2.3",
|
||||
"ts-jest": "^29.0.0",
|
||||
"tslint": "^5.20.1",
|
||||
"tslint-config-airbnb": "^5.11.2",
|
||||
"typescript": "^4.8.4"
|
||||
"typescript": "*"
|
||||
},
|
||||
"lint-staged": {
|
||||
"{src,spec}/**/*.ts": "prettier --write **/*.ts"
|
||||
|
|
16
src/index.ts
16
src/index.ts
|
@ -1,4 +1,4 @@
|
|||
import { ApplicationFunction, Context } from 'probot';
|
||||
import { ApplicationFunction } from 'probot';
|
||||
|
||||
import {
|
||||
backportImpl,
|
||||
|
@ -28,7 +28,12 @@ import {
|
|||
updateBackportValidityCheck,
|
||||
} from './utils/checks-util';
|
||||
import { register } from './utils/prom';
|
||||
import { SimpleWebHookRepoContext, WebHookPR, WebHookPRContext } from './types';
|
||||
import {
|
||||
SimpleWebHookRepoContext,
|
||||
WebHookIssueContext,
|
||||
WebHookPR,
|
||||
WebHookPRContext,
|
||||
} from './types';
|
||||
|
||||
// Built in fetch doesn't support global-agent...
|
||||
// @ts-ignore
|
||||
|
@ -446,8 +451,9 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
|||
);
|
||||
|
||||
// Backport pull requests to labeled targets when PR is merged.
|
||||
robot.on('pull_request.closed', async (context) => {
|
||||
const pr = context.payload.pull_request;
|
||||
robot.on('pull_request.closed', async (context: WebHookPRContext) => {
|
||||
const { pull_request: pr } = context.payload;
|
||||
|
||||
const oldPRNumbers = getPRNumbersFromPRBody(pr, true);
|
||||
if (pr.merged) {
|
||||
if (oldPRNumbers.length > 0) {
|
||||
|
@ -493,7 +499,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
|
|||
const TROP_COMMAND_PREFIX = '/trop ';
|
||||
|
||||
// Manually trigger backporting process on trigger comment phrase.
|
||||
robot.on('issue_comment.created', async (context) => {
|
||||
robot.on('issue_comment.created', async (context: WebHookIssueContext) => {
|
||||
const { issue, comment } = context.payload;
|
||||
|
||||
const isPullRequest = (i: { number: number; html_url: string }) =>
|
||||
|
|
|
@ -9,14 +9,21 @@ export type WebHookPRContext = Context<
|
|||
| 'pull_request.labeled'
|
||||
| 'pull_request.unlabeled'
|
||||
>;
|
||||
|
||||
export type WebHookIssueContext = Context<'issue_comment.created'>;
|
||||
|
||||
export type SimpleWebHookRepoContext = Pick<
|
||||
WebHookRepoContext,
|
||||
'octokit' | 'repo' | 'payload'
|
||||
>;
|
||||
|
||||
export type WebHookRepoContext = Omit<WebHookPRContext, 'payload'> & {
|
||||
payload: Omit<
|
||||
WebHookPRContext['payload'],
|
||||
'pull_request' | 'number' | 'action'
|
||||
>;
|
||||
};
|
||||
|
||||
export type WebHookPR = WebHookPRContext['payload']['pull_request'];
|
||||
|
||||
export type WebHookIssueComment = WebHookIssueContext['payload']['comment'];
|
||||
|
|
|
@ -24,6 +24,7 @@ import { TryBackportOptions } from './interfaces';
|
|||
import { client, register } from './utils/prom';
|
||||
import {
|
||||
SimpleWebHookRepoContext,
|
||||
WebHookIssueContext,
|
||||
WebHookPR,
|
||||
WebHookRepoContext,
|
||||
} from './types';
|
||||
|
@ -251,7 +252,7 @@ const tryBackportSquashCommit = async (opts: TryBackportOptions) => {
|
|||
};
|
||||
|
||||
export const isAuthorizedUser = async (
|
||||
context: Context<'issue_comment'>,
|
||||
context: WebHookIssueContext,
|
||||
username: string,
|
||||
) => {
|
||||
const { data } = await context.octokit.repos.getCollaboratorPermissionLevel(
|
||||
|
|
1272
yarn.lock
1272
yarn.lock
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче