Skip to content

Commit 8faaa0c

Browse files
committed
feat(tasks): skippable tasks for N/A & POST-MERGE
1 parent 856168a commit 8faaa0c

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ Inside your GitHub repo > Settings > Branches > Branch protection rules > Add ru
5454

5555
By default, we mark the check as in_progress until all tasks pass and then it marks it as successful.
5656

57+
## Skippable tasks
58+
59+
Tasks that contain "POST-MERGE" or "N/A" in all caps are skipped. This is useful for tasks that are not applicable to the PR, or tasks that are only applicable after the PR is merged.
60+
This was inspired by [another project here](https://github.com/Shopify/task-list-checker/tree/main?tab=readme-ov-file#in-a-pull-request).
61+
5762
## TODO
5863

5964
- [x] ~~unit tests & travis CI~~

src/check-outstanding-tasks.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ module.exports = function (body) {
2020
// and filter down to just the task list items
2121
let listItems = allTokens.filter(token => token.type === 'list_item');
2222

23+
// filter out skippable items, case sensitive
24+
let skippable = [
25+
'POST-MERGE',
26+
'N/A',
27+
];
28+
listItems = listItems.filter(item => {
29+
return ! skippable.some(skip => item.text.indexOf(skip) !== -1);
30+
});
31+
2332
// return counts of task list items and how many are left to be completed
2433
return {
2534
total: listItems.filter(item => item.checked !== undefined).length,

tests/index.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,18 @@ Hello World
6060
expect(results.total).toBe(5);
6161
expect(results.remaining).toBe(2);
6262
});
63+
64+
test('Test skip items', () => {
65+
let markdown = `
66+
Hello World
67+
- normal
68+
- [ ] task one
69+
- [ ] POST-MERGE: abc
70+
- [ ] this is not a post-merge test
71+
- [ ] N/A skipped
72+
- [x] n/a not skipped
73+
`;
74+
let results = checkOutstandingTasks(markdown);
75+
expect(results.total).toBe(3);
76+
expect(results.remaining).toBe(2);
77+
});

0 commit comments

Comments
 (0)