Skip to content

Commit

Permalink
Improve linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rtsao committed Oct 24, 2017
1 parent caf8241 commit 799899d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"env": {
"node": true,
"es6": true
},
"plugins": [
"prettier"
],
Expand Down
2 changes: 2 additions & 0 deletions __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-env jest */

const t = require('assert');

test('dummy test', () => {
Expand Down
31 changes: 20 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"issue-regex": "^1.0.0",
"probot": "^0.11.0"
"probot": "^3.0.0"
},
"devDependencies": {
"eslint": "^4.8.0",
Expand Down

0 comments on commit 799899d

Please sign in to comment.