9th April 2023
Working through a large pull request (PR) review on GitHub often means jumping around, trying to determine how different pieces of the code interact, or getting pulled away to work on something completely different. When there are tens or even hundreds of files to review it can be easy to lose track of where you are.
Thankfully GitHub offers us the ability to mark a file as reviewed. Clicking the checkbox collapses the view of that particular file, so even if we walk away and come back to it later, we know that particular file has been reviewed.
Even better; if you finish reviewing all the files in a PR and check all those boxes, when any new commits are pushed it only un-checks the files that have been updated, so you don’t end up re-reviewing files that haven’t changed.
Sometimes though, it becomes necessary to re-review everything. Unfortunately, GitHub doesn't provide any way of checking or un-checking all the boxes at once. Thankfully, one handy little snippet is all we need to get the job done;
document.querySelectorAll(".js-reviewed-checkbox").forEach(checkbox => !checkbox.checked && checkbox.click());
If you want to start from scratch, marking all the files as un-viewed, use this code instead;
document.querySelectorAll(".js-reviewed-checkbox").forEach(checkbox => checkbox.checked && checkbox.click());
Then all the files will be marked as un-viewed, ready to be reviewed again.