-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathgenerateIssueBody.ts
More file actions
38 lines (31 loc) · 1.42 KB
/
generateIssueBody.ts
File metadata and controls
38 lines (31 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type {Finding} from './types.d.js'
export function generateIssueBody(finding: Finding, screenshotRepo: string): string {
const solutionLong = finding.solutionLong
?.split('\n')
.map((line: string) =>
!line.trim().startsWith('Fix any') && !line.trim().startsWith('Fix all') && line.trim() !== ''
? `- ${line}`
: line,
)
.join('\n')
let screenshotSection
if (finding.screenshotId) {
const screenshotUrl = `https://github.com/${screenshotRepo}/blob/gh-cache/.screenshots/${finding.screenshotId}.png`
screenshotSection = `
[View screenshot](${screenshotUrl})
`
}
const acceptanceCriteria = `## Acceptance Criteria
- [ ] The specific violation reported in this issue is no longer reproducible.
- [ ] The fix MUST meet WCAG 2.1 guidelines OR the accessibility standards specified by the repository or organization.
- [ ] A test SHOULD be added to ensure this specific violation does not regress.
- [ ] This PR MUST NOT introduce any new accessibility issues or regressions.`
const body = `## What
An accessibility scan ${finding.html ? `flagged the element \`${finding.html}\`` : `found an issue on ${finding.url}`} because ${finding.problemShort}. Learn more about why this was flagged by visiting ${finding.problemUrl}.
${screenshotSection ?? ''}
To fix this, ${finding.solutionShort}.
${solutionLong ? `\nSpecifically:\n\n${solutionLong}` : ''}
${acceptanceCriteria}
`
return body
}