Skip to content
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

Add ESLint #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
"extends": "babel",
"plugins": [
"jest",
"jasmine",
],
"rules": {
"indent": ["error", 4],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just eliminate all the overrides and just run --fix

"quotes": ["error", "single"],
"max-len": "off",
"arrow-parens": "off",
},
"env": {
"node": true,
"jest": true,
"jasmine": true,
},
};
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"package": "npm run clean && npm run build && npm run bundle",
"test": "jest & npm run flow",
"build": "babel src --out-dir dist --ignore __tests__",
"flow": "flow check"
"flow": "flow check",
"eslint": "eslint src/ --format=codeframe"
},
"author": "Andrew Levine",
"license": "MIT",
Expand All @@ -22,6 +23,7 @@
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-eslint": "^7.1.1",
"babel-plugin-transform-async-to-generator": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-es2015-destructuring": "^6.19.0",
Expand All @@ -30,6 +32,11 @@
"babel-plugin-transform-es2015-spread": "^6.8.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-plugin-transform-object-rest-spread": "^6.20.2",
"eslint": "^3.18.0",
"eslint-config-babel": "^6.0.0",
"eslint-plugin-flowtype": "^2.30.3",
"eslint-plugin-jasmine": "^2.2.0",
"eslint-plugin-jest": "^19.0.1",
"flow-bin": "^0.37.4",
"jest": "^18.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type IssueCommentParams = {
// https://developer.github.com/v3/issues/comments/#delete-a-comment
exports.deleteIssueComment = ({ id, owner, repo }: IssueCommentParams) => {
return del(`/repos/${owner}/${repo}/issues/comments/${id}`);
}
};

type IssueParams = {
content: string;
Expand All @@ -90,4 +90,4 @@ exports.createIssueReaction = ({ content, number, owner, repo }: IssueParams) =>
json: true,
body: JSON.stringify({ content })
}).then(({ body }) => body);
}
};
4 changes: 2 additions & 2 deletions src/handlers/issue_comment/created.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import github from '../../github';
import Logger from '../../logger';
import { oneLine } from 'common-tags'
import { oneLine } from 'common-tags';

const { log } = new Logger('handlers/issue_comment/created.js');

Expand Down Expand Up @@ -46,7 +46,7 @@ const isAnnoying = (body) => body === '+1' || body === '-1';
export default function({ comment, issue, repository }: IssueCommentPayload) {

if (isAnnoying(comment.body.trim())) {
log(`Removing a +1/-1 comment`, 'verbose');
log('Removing a +1/-1 comment', 'verbose');
github.deleteIssueComment({
id: comment.id,
owner: repository.owner.login,
Expand Down
1 change: 0 additions & 1 deletion src/handlers/issues/__tests__/labeled.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import handler from '../labeled';
import fs from 'fs';

const wrongLabelPayload = require('./__fixtures__/other-label-added.json');
const needsInfoPayload = require('./__fixtures__/info-label-added.json');
Expand Down
1 change: 0 additions & 1 deletion src/handlers/issues/__tests__/opened.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import handler from '../opened';
import fs from 'fs';

const payload = require('./__fixtures__/new-issue-opened.json');
jest.mock('../../../github', () => ({
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/issues/opened.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export default function({ issue, repository }: OpenedIssuePayload) {
return github.getUserOrgs(issueSubmitter).then(orgs => {
const isBabelOrgMember = orgs.filter(({ login }) => login === 'babel').length;
if (isBabelOrgMember) {
log(`User is member of Babel org. Skipping comment`, 'verbose');
log('User is member of Babel org. Skipping comment', 'verbose');
return;
};
}

log(`User is not member of Babel org. Adding comment`, 'verbose');
log('User is not member of Babel org. Adding comment', 'verbose');
return github.addIssueComment(issue.number, owner, repo, msg);
}).catch(e => {
log(`Failed attempting to add new issue comment. Details: ${e.message}`);
Expand Down
7 changes: 4 additions & 3 deletions src/handlers/pull_request/opened.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function issuesFromBody(body: string) {
if (!fixedList) return [];

const reID = /#(\d+)/g;
let val, ids = [];
let val = [];
const ids = [];
while ((val = reID.exec(fixedList)) !== null) {
ids.push(val[1]);
}
Expand All @@ -39,7 +40,7 @@ export default function({ number, pull_request, repository }: OpenedPRPayload) {
const issues = issuesFromBody(body);
if (!issues.length) {
log(`No issues found for PR #${number}`, 'verbose');
return
return;
}

const { name: repo, owner: { login } } = repository;
Expand All @@ -55,6 +56,6 @@ export default function({ number, pull_request, repository }: OpenedPRPayload) {
Promise.all(requests).then(() => {
log(`Submitted labels for PR ${number} on issues: ${issuesStr}`, 'verbose');
}).catch(e => {
log(`Failed submitted labels for PR ${number} on at least one of ${issuesStr}`);
log(`Failed submitted labels for PR ${number} on at least one of ${issuesStr}. Details: ${e.message}`);
});
}
2 changes: 1 addition & 1 deletion src/handlers/status/failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const buildFailureMsg = (prOwner: string, failedBuilds: Array<JobItem>, owner, r
};

export default function(payload: FailedStatusPayload) {
const { repository: repo, target_url } = payload;
const { repository: repo } = payload;
const [, buildID] = payload.target_url.match(reBuildID) || [];

log(`Fetching test matrix for TravisCI build #${buildID}`, 'verbose');
Expand Down
Loading