Skip to content

Instantly share code, notes, and snippets.

@pauloportella
Last active November 4, 2024 20:53
Show Gist options
  • Save pauloportella/7bfc0afbb46c7373098013e21f1e5614 to your computer and use it in GitHub Desktop.
Save pauloportella/7bfc0afbb46c7373098013e21f1e5614 to your computer and use it in GitHub Desktop.
How to setup conventional comments on Github

Conventional comments

Source

You can add all conventional comments Labels to Github as a saved replies by following the following steps:

  1. Go to https://github.com/settings/replies
  2. Open Developer Tools
  3. Copy/Paste above code in JavaScript console
  4. Press enter
{
  const LABELS = [
    ["👏 praise", "Praises highlight something positive. Try to leave at least one of these comments per review (if it exists :^)"],
    ["🤓 nitpick", "Nitpicks are small, trivial, but necessary changes. Distinguishing nitpick comments significantly helps direct the reader's attention to comments requiring more involvement."],
    ["🎯 suggestion", "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", "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