Skip to content

Commit 7ab62ae

Browse files
authored
fix: Format “Fix all” and “Fix any” as lists in issue bodies (#4)
Fixes github-community-projects/continuous-ai-for-accessibility-scanner#3 To test this PR, I [ran this branch’s workflow](https://github.com/github/accessibility-sandbox/actions/runs/16656045987) and inspected [the issue it created](github/accessibility-sandbox#4337) (links accessible to Hubbers).
2 parents 8430d5c + f44ede0 commit 7ab62ae

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/fileIssueForResult.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ export async function fileIssueForResult(octokit: Octokit, repoWithOwner: string
77
const owner = repoWithOwner.split('/')[0];
88
const repo = repoWithOwner.split('/')[1];
99
const title = `Accessibility issue: ${result.problemShort[0].toUpperCase() + result.problemShort.slice(1)} on ${new URL(result.url).pathname}`;
10+
const solutionLong = result.solutionLong
11+
?.split("\n")
12+
.map((line) =>
13+
!line.trim().startsWith("Fix any") &&
14+
!line.trim().startsWith("Fix all") &&
15+
line.trim() !== ""
16+
? `- ${line}`
17+
: line
18+
)
19+
.join("\n");
1020
const body = `
1121
An accessibility scan flagged the element \`${result.html}\` on ${result.url} because ${result.problemShort}. Learn more about why this was flagged by visiting ${result.problemUrl}.
1222
1323
To fix this, ${result.solutionShort}.
14-
${result.solutionLong ? `\nSpecifically:\n\n${result.solutionLong}` : ''}
24+
${solutionLong ? `\nSpecifically:\n\n${solutionLong}` : ''}
1525
`;
1626

1727
return await octokit.request(`POST /repos/${owner}/${repo}/issues`, {

0 commit comments

Comments
 (0)