master
1import { define, linkIssue } from '#src'
2
3export default define({
4 url: import.meta.url,
5 badges: ['polite-coder', 'rebel-coder'] as const,
6 present(data, grant) {
7 if (data.issues.length <= 10) {
8 return
9 }
10
11 const politeRegexp = /thanks?|please/i
12
13 const politeIssues = data.issues.filter(
14 (issue) =>
15 politeRegexp.test(issue.title) || politeRegexp.test(issue.body),
16 )
17
18 if (politeIssues.length > 0) {
19 grant('polite-coder', 'I am a polite coder.').evidence(
20 'I use words like "thanks" and "please" in my issues:\n\n' +
21 politeIssues
22 .slice(0, 5)
23 .map((x) => `- ${linkIssue(x)}: ${x.title}`)
24 .join('\n') +
25 (politeIssues.length > 5 ? '\n\n And many more...' : ''),
26 )
27 } else {
28 grant('rebel-coder', 'I am a rebel coder.').evidence(
29 'I do not use words like "thanks" and "please" in my issues.\n' +
30 'Straight to the point!',
31 )
32 }
33 },
34})