Skip to content

Commit 6e2bf85

Browse files
Copilotlindseywild
andcommitted
Add Prettier and ESLint with all violations fixed
Co-authored-by: lindseywild <35239154+lindseywild@users.noreply.github.com>
1 parent 86a52fe commit 6e2bf85

23 files changed

Lines changed: 179 additions & 199 deletions

.github/actions/auth/src/index.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { AuthContextOutput } from "./types.d.js";
2-
import crypto from "node:crypto";
32
import process from "node:process";
4-
import * as url from "node:url";
53
import core from "@actions/core";
64
import playwright from "playwright";
75

@@ -18,13 +16,6 @@ export default async function () {
1816
const password = core.getInput("password", { required: true });
1917
core.setSecret(password);
2018

21-
// Determine storage path for authenticated session state
22-
// Playwright will create missing directories, if needed
23-
const actionDirectory = `${url.fileURLToPath(new URL(import.meta.url))}/..`;
24-
const sessionStatePath = `${
25-
process.env.RUNNER_TEMP ?? actionDirectory
26-
}/.auth/${crypto.randomUUID()}/sessionState.json`;
27-
2819
// Launch a headless browser
2920
browser = await playwright.chromium.launch({
3021
headless: true,
@@ -76,13 +67,19 @@ export default async function () {
7667
username,
7768
password,
7869
cookies,
79-
localStorage: origins.reduce((acc, { origin, localStorage }) => {
80-
acc[origin] = localStorage.reduce((acc, { name, value }) => {
81-
acc[name] = value;
70+
localStorage: origins.reduce(
71+
(acc, { origin, localStorage }) => {
72+
acc[origin] = localStorage.reduce(
73+
(acc, { name, value }) => {
74+
acc[name] = value;
75+
return acc;
76+
},
77+
{} as Record<string, string>,
78+
);
8279
return acc;
83-
}, {} as Record<string, string>);
84-
return acc;
85-
}, {} as Record<string, Record<string, string>>),
80+
},
81+
{} as Record<string, Record<string, string>>,
82+
),
8683
};
8784
core.setOutput("auth_context", JSON.stringify(authContextOutput));
8885
core.debug("Output: 'auth_context'");

.github/actions/file/src/Issue.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export class Issue implements IssueInput {
5252
issueNumber: number;
5353
} {
5454
const { owner, repository, issueNumber } =
55-
/\/(?<owner>[^/]+)\/(?<repository>[^/]+)\/issues\/(?<issueNumber>\d+)(?:[/?#]|$)/.exec(
56-
this.#url
57-
)?.groups || {};
55+
/\/(?<owner>[^/]+)\/(?<repository>[^/]+)\/issues\/(?<issueNumber>\d+)(?:[/?#]|$)/.exec(this.#url)?.groups || {};
5856
if (!owner || !repository || !issueNumber) {
5957
throw new Error(`Could not parse issue URL: ${this.#url}`);
6058
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Octokit } from '@octokit/core';
2-
import { Issue } from './Issue.js';
1+
import type { Octokit } from "@octokit/core";
2+
import { Issue } from "./Issue.js";
33

44
export async function closeIssue(octokit: Octokit, { owner, repository, issueNumber }: Issue) {
55
return octokit.request(`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`, {
66
owner,
77
repository,
88
issue_number: issueNumber,
9-
state: 'closed'
9+
state: "closed",
1010
});
11-
}
11+
}
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
import type { Finding } from "./types.d.js";
22

3-
export function generateIssueBody(finding: Finding, repoWithOwner: string): string {
3+
export function generateIssueBody(finding: Finding, _repoWithOwner: string): string {
44
const solutionLong = finding.solutionLong
5-
?.split("\n")
6-
.map((line: string) =>
7-
!line.trim().startsWith("Fix any") &&
8-
!line.trim().startsWith("Fix all") &&
9-
line.trim() !== ""
10-
? `- ${line}`
11-
: line
12-
)
13-
.join("\n");
14-
const acceptanceCriteria = `## Acceptance Criteria
5+
?.split("\n")
6+
.map((line: string) =>
7+
!line.trim().startsWith("Fix any") && !line.trim().startsWith("Fix all") && line.trim() !== ""
8+
? `- ${line}`
9+
: line,
10+
)
11+
.join("\n");
12+
const acceptanceCriteria = `## Acceptance Criteria
1513
- [ ] The specific axe violation reported in this issue is no longer reproducible.
1614
- [ ] The fix MUST meet WCAG 2.1 guidelines OR the accessibility standards specified by the repository or organization.
1715
- [ ] A test SHOULD be added to ensure this specific axe violation does not regress.
1816
- [ ] This PR MUST NOT introduce any new accessibility issues or regressions.
1917
`;
20-
const body = `## What
18+
const body = `## What
2119
An accessibility scan flagged the element \`${finding.html}\` on ${finding.url} because ${finding.problemShort}. Learn more about why this was flagged by visiting ${finding.problemUrl}.
2220
2321
To fix this, ${finding.solutionShort}.
24-
${solutionLong ? `\nSpecifically:\n\n${solutionLong}` : ''}
22+
${solutionLong ? `\nSpecifically:\n\n${solutionLong}` : ""}
2523
2624
${acceptanceCriteria}
2725
`;
2826

2927
return body;
3028
}
31-

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ const OctokitWithThrottling = Octokit.plugin(throttling);
1515

1616
export default async function () {
1717
core.info("Started 'file' action");
18-
const findings: Finding[] = JSON.parse(
19-
core.getInput("findings", { required: true })
20-
);
18+
const findings: Finding[] = JSON.parse(core.getInput("findings", { required: true }));
2119
const repoWithOwner = core.getInput("repository", { required: true });
2220
const token = core.getInput("token", { required: true });
2321
const cachedFilings: (ResolvedFiling | RepeatedFiling)[] = JSON.parse(
24-
core.getInput("cached_filings", { required: false }) || "[]"
22+
core.getInput("cached_filings", { required: false }) || "[]",
2523
);
2624
core.debug(`Input: 'findings: ${JSON.stringify(findings)}'`);
2725
core.debug(`Input: 'repository: ${repoWithOwner}'`);
@@ -31,18 +29,14 @@ export default async function () {
3129
auth: token,
3230
throttle: {
3331
onRateLimit: (retryAfter, options, octokit, retryCount) => {
34-
octokit.log.warn(
35-
`Request quota exhausted for request ${options.method} ${options.url}`
36-
);
32+
octokit.log.warn(`Request quota exhausted for request ${options.method} ${options.url}`);
3733
if (retryCount < 3) {
3834
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
3935
return true;
4036
}
4137
},
4238
onSecondaryRateLimit: (retryAfter, options, octokit, retryCount) => {
43-
octokit.log.warn(
44-
`Secondary rate limit hit for request ${options.method} ${options.url}`
45-
);
39+
octokit.log.warn(`Secondary rate limit hit for request ${options.method} ${options.url}`);
4640
if (retryCount < 3) {
4741
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
4842
return true;
@@ -62,7 +56,7 @@ export default async function () {
6256
} else if (isNewFiling(filing)) {
6357
// Open a new issue for the filing
6458
response = await openIssue(octokit, repoWithOwner, filing.findings[0]);
65-
(filing as any).issue = { state: "open" } as Issue;
59+
(filing as unknown as { issue: Partial<Issue> }).issue = { state: "open" };
6660
} else if (isRepeatedFiling(filing)) {
6761
// Reopen the filing’s issue (if necessary)
6862
response = await reopenIssue(octokit, new Issue(filing.issue));
@@ -75,7 +69,7 @@ export default async function () {
7569
filing.issue.url = response.data.html_url;
7670
filing.issue.title = response.data.title;
7771
core.info(
78-
`Set issue ${response.data.title} (${repoWithOwner}#${response.data.number}) state to ${filing.issue.state}`
72+
`Set issue ${response.data.title} (${repoWithOwner}#${response.data.number}) state to ${filing.issue.state}`,
7973
);
8074
}
8175
} catch (error) {

.github/actions/file/src/isNewFiling.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@ import type { Filing, NewFiling } from "./types.d.js";
22

33
export function isNewFiling(filing: Filing): filing is NewFiling {
44
// A Filing without an issue is new
5-
return (
6-
(!("issue" in filing) || !filing.issue?.url) &&
7-
"findings" in filing &&
8-
filing.findings.length > 0
9-
);
5+
return (!("issue" in filing) || !filing.issue?.url) && "findings" in filing && filing.findings.length > 0;
106
}

.github/actions/file/src/isRepeatedFiling.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,5 @@ import type { Filing, RepeatedFiling } from "./types.d.js";
22

33
export function isRepeatedFiling(filing: Filing): filing is RepeatedFiling {
44
// A Filing with an issue and findings is a repeated filing
5-
return (
6-
"findings" in filing &&
7-
filing.findings.length > 0 &&
8-
"issue" in filing &&
9-
!!filing.issue?.url
10-
);
5+
return "findings" in filing && filing.findings.length > 0 && "issue" in filing && !!filing.issue?.url;
116
}

.github/actions/file/src/isResolvedFiling.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@ import type { Filing, ResolvedFiling } from "./types.d.js";
22

33
export function isResolvedFiling(filing: Filing): filing is ResolvedFiling {
44
// A Filing without findings is resolved
5-
return (
6-
(!("findings" in filing) || filing.findings.length === 0) &&
7-
"issue" in filing &&
8-
!!filing.issue?.url
9-
);
5+
return (!("findings" in filing) || filing.findings.length === 0) && "issue" in filing && !!filing.issue?.url;
106
}

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

Lines changed: 7 additions & 7 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,12 +14,12 @@ 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

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

2424
const labels = [`${finding.scannerType} rule: ${finding.ruleId}`, `${finding.scannerType}-scanning-issue`];
2525
const title = truncateWithEllipsis(
@@ -34,6 +34,6 @@ export async function openIssue(octokit: Octokit, repoWithOwner: string, finding
3434
repo,
3535
title,
3636
body,
37-
labels
37+
labels,
3838
});
3939
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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) {
4+
export async function reopenIssue(octokit: Octokit, { owner, repository, issueNumber }: Issue) {
55
return octokit.request(`PATCH /repos/${owner}/${repository}/issues/${issueNumber}`, {
66
owner,
77
repository,
88
issue_number: issueNumber,
9-
state: 'open'
9+
state: "open",
1010
});
1111
}

0 commit comments

Comments
 (0)