Skip to content

Commit

Permalink
Update: needs info label behavior (refs #136) (#155)
Browse files Browse the repository at this point in the history
* Update: needs info label behavior (refs #136)

* fix where labels are checked

* Update src/plugins/needs-info/index.js

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
  • Loading branch information
nzakas and mdjermanovic committed Sep 24, 2021
1 parent 679cafd commit c3d6171
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
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);
};
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

0 comments on commit c3d6171

Please sign in to comment.