-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conventional comments setup #5358
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* eslint-disable max-len */ | ||
|
||
/** | ||
* Novu Conventional Comments as GitHub Saved Replies | ||
* Based on https://gist.github.com/ifyoumakeit/4148a8c3e61b7868935651272c03f793 | ||
* | ||
* To install: | ||
* 1. Go to https://github.com/settings/replies | ||
* 2. Open Developer Tools | ||
* 3. Paste and run below code in JavaScript console | ||
*/ | ||
|
||
(async function generateReplies(document) { | ||
// https://conventionalcomments.org/#labels | ||
const LABEL = { | ||
praise: 'praise', | ||
note: 'note', | ||
nitpick: 'nitpick', | ||
thought: 'thought', | ||
suggestion: 'suggestion', | ||
question: 'question', | ||
chore: 'chore', | ||
issue: 'issue', | ||
}; | ||
|
||
const NON_BLOCKING = [LABEL.nitpick, LABEL.thought, LABEL.note]; | ||
|
||
const COMMENT = { | ||
[LABEL.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.', | ||
[LABEL.note]: 'Notes are always non-blocking and simply highlight something the reader should take note of.', | ||
[LABEL.nitpick]: 'Nitpicks are trivial preference-based requests. These should be non-blocking by nature.', | ||
[LABEL.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.', | ||
[LABEL.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.", | ||
[LABEL.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.", | ||
[LABEL.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.', | ||
[LABEL.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.', | ||
}; | ||
|
||
function post(key, token) { | ||
const blockingText = NON_BLOCKING.includes(key) ? ' (non-blocking)' : ''; | ||
|
||
return fetch('replies', { | ||
headers: { 'content-type': 'application/x-www-form-urlencoded' }, | ||
method: 'POST', | ||
mode: 'cors', | ||
credentials: 'include', | ||
body: new URLSearchParams({ | ||
body: `<!-- ${COMMENT[key]} -->\n**${key}${blockingText}:** `, | ||
authenticity_token: token, | ||
title: `${key[0].toUpperCase()}${key.slice(1)}${blockingText}`, | ||
}).toString(), | ||
}); | ||
} | ||
|
||
const form = document.querySelector('.new_saved_reply'); | ||
const token = form.querySelector('[name=authenticity_token]').value; | ||
// Replies are order alphabetically, so order doesn't need to preserved. | ||
await Promise.all(Object.keys(LABEL).map((key) => post(key, token))); | ||
console.log('All added! Refresh the page!'); | ||
})(window.document); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Neat 👌🏼