Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save csouchet/0a1bbe1f962e42d426db636315fbe167 to your computer and use it in GitHub Desktop.
Save csouchet/0a1bbe1f962e42d426db636315fbe167 to your computer and use it in GitHub Desktop.
GitHub Conventional Comments (instructions to install in comment below code)
(async function generateReplies(document) {
// https://conventionalcomments.org/#labels
const COMMENTS = [
["🙌 praise", "Praises highlight something positive. Try to leave at least one of these comments per review. Do not leave false praise (which can actually be damaging). Do look for something to sincerely praise."],
["🧐 nitpick", "Nitpicks are trivial preference-based requests. These should be non-blocking by nature."],
["🚀 suggestion", "Suggestions propose improvements to the current subject. It's important to be explicit and clear on what is being suggested and why it is an improvement. Consider using patches and the blocking or non-blocking decorations to further communicate your intent."],
["🛠️ issue", "Issues highlight specific problems with the subject under review. These problems can be user-facing or behind the scenes. It is strongly recommended to pair this comment with a suggestion. If you are not sure if a problem exists or not, consider leaving a question."],
["📌 todo", "TODO's are small, trivial, but necessary changes. Distinguishing todo comments from issues: or suggestions: helps direct the reader's attention to comments requiring more involvement."],
["❓ question", "Questions are appropriate if you have a potential concern but are not quite sure if it's relevant or not. Asking the author for clarification or investigation can lead to a quick resolution."],
["💡 thought", "Thoughts represent an idea that popped up from reviewing. These comments are non-blocking by nature, but they are extremely valuable and can lead to more focused initiatives and mentoring opportunities."],
["🧹 chore", "Chores are simple tasks that must be done before the subject can be “officially” accepted. Usually, these comments reference some common process. Try to leave a link to the process description so that the reader knows how to resolve the chore."],
["🗒️ note", "Notes are always non-blocking and simply highlight something the reader should take note of."],
["📝 typo", "Typo comments are like todo:, where the main issue is a mispelling."],
["✨ polish", "Polish comments are like a suggestion, where there is nothing necessarily wrong with the relevant content, there's just some ways to immediately improve the quality."],
["🤔 quibble", "Quibbles are very much like nitpick:, except it does not conjure up images of lice and animal hygiene practices."],
];
function post(label, comment, token) {
const title = `${label[0].toUpperCase()}${label.slice(1)}`;
const body =
`<!-- ${comment}
Decorations:
- (non-blocking): A comment with this decoration should not prevent the subject under review from being accepted. This is helpful for organizations that consider comments blocking by default.
- (blocking): A comment with this decoration should prevent the subject under review from being accepted until it is resolved. This is helpful for organizations that consider comments non-blocking by default.
- (if-minor): This decoration gives some freedom to the author, indicating that they should resolve the comment only if the changes end up being minor or trivial.
-->\n
**${label}(non-blocking/blocking/if-minor):** <subject>
[discussion]`;
return fetch("replies", {
headers: { "content-type": "application/x-www-form-urlencoded" },
method: "POST",
mode: "cors",
credentials: "include",
body: new URLSearchParams({
body: body,
authenticity_token: token,
title: title,
}).toString(),
});
}
const form = document.querySelector(".new_saved_reply");
const authenticity_token = form.querySelector("[name=authenticity_token]").value;
// Replies are order alphabetically, so order doesn't need to preserved.
await Promise.all(COMMENTS.map(([label, comment]) => post(label, comment, authenticity_token)));
console.log("All added! Refresh the page!");
})(window.document);
@csouchet
Copy link
Author

GitHub Conventional Comments!

Conventional Comments is a standard for formatting comments of any kind of review/feedback process. GitHub Saved Replies are re-usable text snippets that you can use throughout GitHub comment fields. Combining the two gives you GitHub Conventional Comments!

How to install

  1. Go to https://github.com/settings/replies
  2. Open Developer Tools of your browser
  3. Paste and run the above code in the JavaScript console

How to add a conventional comment

Go to a Pull Request or Issue comment box and press CTRL + . or click the reply button.

Note: doesn't work in gists.

@csouchet
Copy link
Author

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment