Skip to content

Commit 41e9a3b

Browse files
committed
More files
1 parent 310d936 commit 41e9a3b

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

.github/actions/file/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ const OctokitWithThrottling = Octokit.plugin(throttling);
1616
export default async function () {
1717
core.info("Started 'file' action");
1818
const findings: Finding[] = JSON.parse(
19-
core.getInput("findings", { required: true })
19+
core.getInput("findings", { required: true }),
2020
);
2121
const repoWithOwner = core.getInput("repository", { required: true });
2222
const token = core.getInput("token", { required: true });
2323
const cachedFilings: (ResolvedFiling | RepeatedFiling)[] = JSON.parse(
24-
core.getInput("cached_filings", { required: false }) || "[]"
24+
core.getInput("cached_filings", { required: false }) || "[]",
2525
);
2626
core.debug(`Input: 'findings: ${JSON.stringify(findings)}'`);
2727
core.debug(`Input: 'repository: ${repoWithOwner}'`);
@@ -32,7 +32,7 @@ export default async function () {
3232
throttle: {
3333
onRateLimit: (retryAfter, options, octokit, retryCount) => {
3434
octokit.log.warn(
35-
`Request quota exhausted for request ${options.method} ${options.url}`
35+
`Request quota exhausted for request ${options.method} ${options.url}`,
3636
);
3737
if (retryCount < 3) {
3838
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
@@ -41,7 +41,7 @@ export default async function () {
4141
},
4242
onSecondaryRateLimit: (retryAfter, options, octokit, retryCount) => {
4343
octokit.log.warn(
44-
`Secondary rate limit hit for request ${options.method} ${options.url}`
44+
`Secondary rate limit hit for request ${options.method} ${options.url}`,
4545
);
4646
if (retryCount < 3) {
4747
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
@@ -76,7 +76,7 @@ export default async function () {
7676
filing.issue.url = response.data.html_url;
7777
filing.issue.title = response.data.title;
7878
core.info(
79-
`Set issue ${response.data.title} (${repoWithOwner}#${response.data.number}) state to ${filing.issue.state}`
79+
`Set issue ${response.data.title} (${repoWithOwner}#${response.data.number}) state to ${filing.issue.state}`,
8080
);
8181
}
8282
} catch (error) {

.github/actions/file/src/openIssue.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Octokit } from '@octokit/core';
2-
import type { Finding } from './types.d.js';
1+
import type { Octokit } from "@octokit/core";
2+
import type { Finding } from "./types.d.js";
33
import { generateIssueBody } from "./generateIssueBody.js";
4-
import * as url from 'node:url'
4+
import * as url from "node:url";
55
const URL = url.URL;
66

77
/** Max length for GitHub issue titles */
@@ -14,14 +14,21 @@ const GITHUB_ISSUE_TITLE_MAX_LENGTH = 256;
1414
* @returns Either the original text or a truncated version with an ellipsis
1515
*/
1616
function truncateWithEllipsis(text: string, maxLength: number): string {
17-
return text.length > maxLength ? text.slice(0, maxLength - 1) + '…' : text;
17+
return text.length > maxLength ? text.slice(0, maxLength - 1) + "…" : text;
1818
}
1919

20-
export async function openIssue(octokit: Octokit, repoWithOwner: string, finding: Finding) {
21-
const owner = repoWithOwner.split('/')[0];
22-
const repo = repoWithOwner.split('/')[1];
20+
export async function openIssue(
21+
octokit: Octokit,
22+
repoWithOwner: string,
23+
finding: Finding,
24+
) {
25+
const owner = repoWithOwner.split("/")[0];
26+
const repo = repoWithOwner.split("/")[1];
2327

24-
const labels = [`${finding.scannerType} rule: ${finding.ruleId}`, `${finding.scannerType}-scanning-issue`];
28+
const labels = [
29+
`${finding.scannerType} rule: ${finding.ruleId}`,
30+
`${finding.scannerType}-scanning-issue`,
31+
];
2532
const title = truncateWithEllipsis(
2633
`Accessibility issue: ${finding.problemShort[0].toUpperCase() + finding.problemShort.slice(1)} on ${new URL(finding.url).pathname}`,
2734
GITHUB_ISSUE_TITLE_MAX_LENGTH,
@@ -34,6 +41,6 @@ export async function openIssue(octokit: Octokit, repoWithOwner: string, finding
3441
repo,
3542
title,
3643
body,
37-
labels
44+
labels,
3845
});
3946
}
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import type { Octokit } from '@octokit/core';
2-
import type { Issue } from './Issue.js';
1+
import type { Octokit } from "@octokit/core";
2+
import type { Issue } from "./Issue.js";
33

4-
export async function reopenIssue(octokit: Octokit, { owner, repository, issueNumber}: Issue) {
5-
return octokit.request(`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`, {
6-
owner,
7-
repository,
8-
issue_number: issueNumber,
9-
state: 'open'
10-
});
4+
export async function reopenIssue(
5+
octokit: Octokit,
6+
{ owner, repository, issueNumber }: Issue,
7+
) {
8+
return octokit.request(
9+
`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`,
10+
{
11+
owner,
12+
repository,
13+
issue_number: issueNumber,
14+
state: "open",
15+
},
16+
);
1117
}

0 commit comments

Comments
 (0)