Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewfritz86/362732f0660113d42904157fdcf579d0 to your computer and use it in GitHub Desktop.
Save andrewfritz86/362732f0660113d42904157fdcf579d0 to your computer and use it in GitHub Desktop.
GitHub Conventional Comments (instructions to install in comment below code)
// Credit Dave Garwacke @ifyoumakeit
{
// https://conventionalcomments.org/#labels
const LABELS = [
["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 small, trivial, but necessary changes. Distinguishing nitpick comments significantly helps direct the reader's attention to comments requiring more involvement."],
["suggestion (blocking)", "Suggestions are specific requests to improve the subject under review. It is assumed that we all want to do what's best, so these comments are never dismissed as “mere suggestions”, but are taken seriously."],
["suggestion (non-blocking)", "Suggestions are specific requests to improve the subject under review. It is assumed that we all want to do what's best, so these comments are never dismissed as “mere suggestions”, but are taken seriously."],
["issue (blocking)", "Issues represent user-facing problems. If possible, it's great to follow this kind of comment with a suggestion."],
["issue (non-blocking)", "Issues represent user-facing problems. If possible, it's great to follow this kind of comment with a suggestion."],
["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."],
];
const form = document.querySelector(".new_saved_reply");
const authenticity_token = encodeURIComponent(
form.querySelector("[name=authenticity_token]").value
);
Promise.all(
LABELS.map(([type, note], index) => {
const title = encodeURIComponent(`${type[0].toUpperCase()}${type.slice(1)}`);
const body = encodeURIComponent(`<!-- ${note} -->\n**${type}:** ‏`);
return fetch("replies", {
headers: {
accept:
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-language": "en-US,en;q=0.9",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
pragma: "no-cache",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
},
referrer: "https://github.com/settings/replies",
referrerPolicy: "strict-origin-when-cross-origin",
body: `authenticity_token=${authenticity_token}&title=${title}&saved_reply_id=&body=${body}&path=&line=&start_line=&preview_side=&preview_start_side=&start_commit_oid=&end_commit_oid=&base_commit_oid=&comment_id=`,
method: "POST",
mode: "cors",
credentials: "include",
})
})
).then(() => console.log("All added! Refresh the page!"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment