diff --git a/.eslintrc b/.eslintrc index 0945db1..c54f270 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,15 @@ { + "extends": "eslint:recommended", "parserOptions": { "ecmaVersion": 2017, "ecmaFeatures": { "experimentalObjectRestSpread": true } }, + "env": { + "node": true, + "es6": true + }, "plugins": [ "prettier" ], diff --git a/__tests__/index.js b/__tests__/index.js index e8e3d25..c97a2b5 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -4,6 +4,8 @@ * LICENSE file in the root directory of this source tree. */ +/* eslint-env jest */ + const t = require('assert'); test('dummy test', () => { diff --git a/index.js b/index.js index d006719..8f7798d 100644 --- a/index.js +++ b/index.js @@ -13,17 +13,26 @@ module.exports = robot => { async function check(context) { const {github} = context; const pr = context.payload.pull_request; - const issues = pr.body.match(issueRegex()); - const status = - issues === null - ? { - state: 'failure', - description: 'PR does not reference an issue', - } - : { - state: 'success', - description: 'PR references an issue', - }; + + function hasIssue() { + const issues = pr.body.match(issueRegex()); + if (issues !== null) { + return true; + } + const repo = context.payload.repository.full_name; + const urlRegex = new RegExp(`${repo}/issues/\\d+`, 'g'); + return pr.body.match(urlRegex) !== null; + } + + const status = hasIssue() + ? { + state: 'success', + description: 'PR references an issue', + } + : { + state: 'failure', + description: 'PR does not reference an issue', + }; setStatus(status); diff --git a/package.json b/package.json index b39043c..092ce1b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "issue-regex": "^1.0.0", - "probot": "^0.11.0" + "probot": "^3.0.0" }, "devDependencies": { "eslint": "^4.8.0",