Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update: needs info label behavior (refs #136) #155

Merged
merged 3 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions src/plugins/needs-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@ const needInfoLabel = "needs info";

/**
* Create the comment for the need info
* @param {string} username - user to tag on the comment
* @returns {string} comment message
* @private
*/
function commentMessage(username) {
function commentMessage() {
return `
Hi @${username}, thanks for the issue. It looks like there's not enough information for us to know how to help you.
It looks like there wasn't enough information for us to know how to help you, so we're closing the issue.

If you're reporting a bug, please be sure to include:

1. The version of ESLint you are using (run \`eslint -v\`)
2. What you did (the source code and ESLint configuration)
3. The actual ESLint output complete with numbers
4. What you expected to happen instead

Requesting a new rule? Please see [Proposing a New Rule](http://eslint.org/docs/developer-guide/contributing/new-rules) for instructions.

Requesting a rule change? Please see [Proposing a Rule Change](http://eslint.org/docs/developer-guide/contributing/rule-changes) for instructions.

If it's something else, please just provide as much additional information as possible. Thanks!
Thanks for your understanding.

[//]: # (needs-info)
`;
Expand All @@ -53,9 +41,9 @@ function hasNeedInfoLabel(label) {
async function check(context) {
const { payload, github } = context;

if (hasNeedInfoLabel(payload.label)) {
if (payload.issue.labels.some(hasNeedInfoLabel)) {
await github.issues.createComment(context.issue({
body: commentMessage(payload.issue.user.login)
body: commentMessage()
}));
}
}
Expand All @@ -65,5 +53,5 @@ async function check(context) {
*/

module.exports = robot => {
robot.on("issues.labeled", check);
robot.on("issues.closed", check);
mdjermanovic marked this conversation as resolved.
Show resolved Hide resolved
};
10 changes: 2 additions & 8 deletions tests/plugins/needs-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("needs-info", () => {
await bot.receive({
name: "issues",
payload: {
action: "labeled",
action: "closed",
installation: {
id: 1
},
Expand All @@ -51,9 +51,6 @@ describe("needs-info", () => {
},
number: 1
},
label: {
name: "needs info"
},
repository: {
name: "repo-test",
owner: {
Expand All @@ -70,7 +67,7 @@ describe("needs-info", () => {
await bot.receive({
name: "issues",
payload: {
action: "labeled",
action: "closed",
installation: {
id: 1
},
Expand All @@ -85,9 +82,6 @@ describe("needs-info", () => {
},
number: 1
},
label: {
name: "triage"
},
repository: {
name: "repo-test",
owner: {
Expand Down