{"action":"created","comment":{"url":"https://api.github.com/repos/kellym/lint-my-pr/pulls/comments/241465711","pull_request_review_id":184745289,"id":241465711,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTQ2NTcxMQ==","diff_hunk":"@@ -0,0 +1,93 @@\n+const { CLIEngine } = require('eslint');\n+const path = require('path');\n+const octokit = require('@octokit/rest')();\n+const parse = require('parse-diff');\n+\n+const stripPath = path.resolve('.');\n+const cli = new CLIEngine({\n+  useEslintrc: true\n+});\n+\n+octokit.authenticate({\n+  type: 'token',\n+  token: process.env.GH_TOKEN\n+})\n+\n+const [owner, repo, number] = ['kellym', 'lint-my-pr', 1];\n+\n+const report = cli.executeOnFiles(['.']);\n+const errors = {};\n+\n+report.results.forEach( err => {\n+  const file = err.filePath.replace(stripPath + '/', '');\n+  errors[file] = errors[file] || [];\n+  err.messages.forEach(m => {\n+    errors[file].push({ line: m.line, message: m.message });\n+  });\n+});\n+\n+const result = octokit.pulls.get({ owner, repo, number, headers: {\n+  accept: 'application/vnd.github.v3.diff'\n+} }).catch(e => {\n+  console.log(\"couldn't authenticate\", e);\n+});\n+\n+\n+const comments = {};\n+\n+result.then(({ data }) => {\n+  data = parse(data);\n+  data.forEach( file => {\n+    if (errors[file.to]) {\n+      const fileErrors = {};\n+      errors[file.to].forEach(({ line, message }) => {\n+        let position = 1;\n+        file.chunks.forEach(chunk => {\n+          if (line >= chunk.newStart && line <= (chunk.newStart + chunk.newLines)) {\n+            const errorPosition = position + (line - chunk.newStart);\n+            fileErrors[errorPosition] = fileErrors[errorPosition] || [];\n+            fileErrors[errorPosition].push(message);\n+          }\n+          position += chunk.newLines;\n+        });\n+      });\n+      comments[file.to] = fileErrors;\n+    }\n+  });\n+  console.log(comments);\n+\n+  const apiCalls = []\n+  octokit.pulls.get({ owner, repo, number }).then(({ data }) => {","path":"lint.js","position":60,"original_position":60,"commit_id":"22090d2a4343c75927b2531ee5a6855a65cdc04c","original_commit_id":"22090d2a4343c75927b2531ee5a6855a65cdc04c","user":{"login":"kellym","id":283371,"node_id":"MDQ6VXNlcjI4MzM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/283371?v=4","gravatar_id":"","url":"https://api.github.com/users/kellym","html_url":"https://github.com/kellym","followers_url":"https://api.github.com/users/kellym/followers","following_url":"https://api.github.com/users/kellym/following{/other_user}","gists_url":"https://api.github.com/users/kellym/gists{/gist_id}","starred_url":"https://api.github.com/users/kellym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellym/subscriptions","organizations_url":"https://api.github.com/users/kellym/orgs","repos_url":"https://api.github.com/users/kellym/repos","events_url":"https://api.github.com/users/kellym/events{/privacy}","received_events_url":"https://api.github.com/users/kellym/received_events","type":"User","site_admin":false},"body":"Missing semicolon.","created_at":"2018-12-13T16:18:47Z","updated_at":"2018-12-13T16:18:47Z","html_url":"https://github.com/kellym/lint-my-pr/pull/1#discussion_r241465711","pull_request_url":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/kellym/lint-my-pr/pulls/comments/241465711"},"html":{"href":"https://github.com/kellym/lint-my-pr/pull/1#discussion_r241465711"},"pull_request":{"href":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1","id":238421791,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4NDIxNzkx","html_url":"https://github.com/kellym/lint-my-pr/pull/1","diff_url":"https://github.com/kellym/lint-my-pr/pull/1.diff","patch_url":"https://github.com/kellym/lint-my-pr/pull/1.patch","issue_url":"https://api.github.com/repos/kellym/lint-my-pr/issues/1","number":1,"state":"open","locked":false,"title":"Lint errors","user":{"login":"kellym","id":283371,"node_id":"MDQ6VXNlcjI4MzM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/283371?v=4","gravatar_id":"","url":"https://api.github.com/users/kellym","html_url":"https://github.com/kellym","followers_url":"https://api.github.com/users/kellym/followers","following_url":"https://api.github.com/users/kellym/following{/other_user}","gists_url":"https://api.github.com/users/kellym/gists{/gist_id}","starred_url":"https://api.github.com/users/kellym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellym/subscriptions","organizations_url":"https://api.github.com/users/kellym/orgs","repos_url":"https://api.github.com/users/kellym/repos","events_url":"https://api.github.com/users/kellym/events{/privacy}","received_events_url":"https://api.github.com/users/kellym/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-13T15:05:09Z","updated_at":"2018-12-13T16:18:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3c6c5b47fb7a26730af06e7c3c3355ce35ca76f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1/commits","review_comments_url":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1/comments","review_comment_url":"https://api.github.com/repos/kellym/lint-my-pr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kellym/lint-my-pr/issues/1/comments","statuses_url":"https://api.github.com/repos/kellym/lint-my-pr/statuses/22090d2a4343c75927b2531ee5a6855a65cdc04c","head":{"label":"kellym:test-pr","ref":"test-pr","sha":"22090d2a4343c75927b2531ee5a6855a65cdc04c","user":{"login":"kellym","id":283371,"node_id":"MDQ6VXNlcjI4MzM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/283371?v=4","gravatar_id":"","url":"https://api.github.com/users/kellym","html_url":"https://github.com/kellym","followers_url":"https://api.github.com/users/kellym/followers","following_url":"https://api.github.com/users/kellym/following{/other_user}","gists_url":"https://api.github.com/users/kellym/gists{/gist_id}","starred_url":"https://api.github.com/users/kellym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellym/subscriptions","organizations_url":"https://api.github.com/users/kellym/orgs","repos_url":"https://api.github.com/users/kellym/repos","events_url":"https://api.github.com/users/kellym/events{/privacy}","received_events_url":"https://api.github.com/users/kellym/received_events","type":"User","site_admin":false},"repo":{"id":161587460,"node_id":"MDEwOlJlcG9zaXRvcnkxNjE1ODc0NjA=","name":"lint-my-pr","full_name":"kellym/lint-my-pr","private":false,"owner":{"login":"kellym","id":283371,"node_id":"MDQ6VXNlcjI4MzM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/283371?v=4","gravatar_id":"","url":"https://api.github.com/users/kellym","html_url":"https://github.com/kellym","followers_url":"https://api.github.com/users/kellym/followers","following_url":"https://api.github.com/users/kellym/following{/other_user}","gists_url":"https://api.github.com/users/kellym/gists{/gist_id}","starred_url":"https://api.github.com/users/kellym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellym/subscriptions","organizations_url":"https://api.github.com/users/kellym/orgs","repos_url":"https://api.github.com/users/kellym/repos","events_url":"https://api.github.com/users/kellym/events{/privacy}","received_events_url":"https://api.github.com/users/kellym/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kellym/lint-my-pr","description":null,"fork":false,"url":"https://api.github.com/repos/kellym/lint-my-pr","forks_url":"https://api.github.com/repos/kellym/lint-my-pr/forks","keys_url":"https://api.github.com/repos/kellym/lint-my-pr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kellym/lint-my-pr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kellym/lint-my-pr/teams","hooks_url":"https://api.github.com/repos/kellym/lint-my-pr/hooks","issue_events_url":"https://api.github.com/repos/kellym/lint-my-pr/issues/events{/number}","events_url":"https://api.github.com/repos/kellym/lint-my-pr/events","assignees_url":"https://api.github.com/repos/kellym/lint-my-pr/assignees{/user}","branches_url":"https://api.github.com/repos/kellym/lint-my-pr/branches{/branch}","tags_url":"https://api.github.com/repos/kellym/lint-my-pr/tags","blobs_url":"https://api.github.com/repos/kellym/lint-my-pr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kellym/lint-my-pr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kellym/lint-my-pr/git/refs{/sha}","trees_url":"https://api.github.com/repos/kellym/lint-my-pr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kellym/lint-my-pr/statuses/{sha}","languages_url":"https://api.github.com/repos/kellym/lint-my-pr/languages","stargazers_url":"https://api.github.com/repos/kellym/lint-my-pr/stargazers","contributors_url":"https://api.github.com/repos/kellym/lint-my-pr/contributors","subscribers_url":"https://api.github.com/repos/kellym/lint-my-pr/subscribers","subscription_url":"https://api.github.com/repos/kellym/lint-my-pr/subscription","commits_url":"https://api.github.com/repos/kellym/lint-my-pr/commits{/sha}","git_commits_url":"https://api.github.com/repos/kellym/lint-my-pr/git/commits{/sha}","comments_url":"https://api.github.com/repos/kellym/lint-my-pr/comments{/number}","issue_comment_url":"https://api.github.com/repos/kellym/lint-my-pr/issues/comments{/number}","contents_url":"https://api.github.com/repos/kellym/lint-my-pr/contents/{+path}","compare_url":"https://api.github.com/repos/kellym/lint-my-pr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kellym/lint-my-pr/merges","archive_url":"https://api.github.com/repos/kellym/lint-my-pr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kellym/lint-my-pr/downloads","issues_url":"https://api.github.com/repos/kellym/lint-my-pr/issues{/number}","pulls_url":"https://api.github.com/repos/kellym/lint-my-pr/pulls{/number}","milestones_url":"https://api.github.com/repos/kellym/lint-my-pr/milestones{/number}","notifications_url":"https://api.github.com/repos/kellym/lint-my-pr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kellym/lint-my-pr/labels{/name}","releases_url":"https://api.github.com/repos/kellym/lint-my-pr/releases{/id}","deployments_url":"https://api.github.com/repos/kellym/lint-my-pr/deployments","created_at":"2018-12-13T05:16:53Z","updated_at":"2018-12-13T15:52:45Z","pushed_at":"2018-12-13T15:54:29Z","git_url":"git://github.com/kellym/lint-my-pr.git","ssh_url":"git@github.com:kellym/lint-my-pr.git","clone_url":"https://github.com/kellym/lint-my-pr.git","svn_url":"https://github.com/kellym/lint-my-pr","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"kellym:master","ref":"master","sha":"434fde5c9febe86ebe2b8682e63bba8f0fb59e4c","user":{"login":"kellym","id":283371,"node_id":"MDQ6VXNlcjI4MzM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/283371?v=4","gravatar_id":"","url":"https://api.github.com/users/kellym","html_url":"https://github.com/kellym","followers_url":"https://api.github.com/users/kellym/followers","following_url":"https://api.github.com/users/kellym/following{/other_user}","gists_url":"https://api.github.com/users/kellym/gists{/gist_id}","starred_url":"https://api.github.com/users/kellym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellym/subscriptions","organizations_url":"https://api.github.com/users/kellym/orgs","repos_url":"https://api.github.com/users/kellym/repos","events_url":"https://api.github.com/users/kellym/events{/privacy}","received_events_url":"https://api.github.com/users/kellym/received_events","type":"User","site_admin":false},"repo":{"id":161587460,"node_id":"MDEwOlJlcG9zaXRvcnkxNjE1ODc0NjA=","name":"lint-my-pr","full_name":"kellym/lint-my-pr","private":false,"owner":{"login":"kellym","id":283371,"node_id":"MDQ6VXNlcjI4MzM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/283371?v=4","gravatar_id":"","url":"https://api.github.com/users/kellym","html_url":"https://github.com/kellym","followers_url":"https://api.github.com/users/kellym/followers","following_url":"https://api.github.com/users/kellym/following{/other_user}","gists_url":"https://api.github.com/users/kellym/gists{/gist_id}","starred_url":"https://api.github.com/users/kellym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellym/subscriptions","organizations_url":"https://api.github.com/users/kellym/orgs","repos_url":"https://api.github.com/users/kellym/repos","events_url":"https://api.github.com/users/kellym/events{/privacy}","received_events_url":"https://api.github.com/users/kellym/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kellym/lint-my-pr","description":null,"fork":false,"url":"https://api.github.com/repos/kellym/lint-my-pr","forks_url":"https://api.github.com/repos/kellym/lint-my-pr/forks","keys_url":"https://api.github.com/repos/kellym/lint-my-pr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kellym/lint-my-pr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kellym/lint-my-pr/teams","hooks_url":"https://api.github.com/repos/kellym/lint-my-pr/hooks","issue_events_url":"https://api.github.com/repos/kellym/lint-my-pr/issues/events{/number}","events_url":"https://api.github.com/repos/kellym/lint-my-pr/events","assignees_url":"https://api.github.com/repos/kellym/lint-my-pr/assignees{/user}","branches_url":"https://api.github.com/repos/kellym/lint-my-pr/branches{/branch}","tags_url":"https://api.github.com/repos/kellym/lint-my-pr/tags","blobs_url":"https://api.github.com/repos/kellym/lint-my-pr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kellym/lint-my-pr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kellym/lint-my-pr/git/refs{/sha}","trees_url":"https://api.github.com/repos/kellym/lint-my-pr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kellym/lint-my-pr/statuses/{sha}","languages_url":"https://api.github.com/repos/kellym/lint-my-pr/languages","stargazers_url":"https://api.github.com/repos/kellym/lint-my-pr/stargazers","contributors_url":"https://api.github.com/repos/kellym/lint-my-pr/contributors","subscribers_url":"https://api.github.com/repos/kellym/lint-my-pr/subscribers","subscription_url":"https://api.github.com/repos/kellym/lint-my-pr/subscription","commits_url":"https://api.github.com/repos/kellym/lint-my-pr/commits{/sha}","git_commits_url":"https://api.github.com/repos/kellym/lint-my-pr/git/commits{/sha}","comments_url":"https://api.github.com/repos/kellym/lint-my-pr/comments{/number}","issue_comment_url":"https://api.github.com/repos/kellym/lint-my-pr/issues/comments{/number}","contents_url":"https://api.github.com/repos/kellym/lint-my-pr/contents/{+path}","compare_url":"https://api.github.com/repos/kellym/lint-my-pr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kellym/lint-my-pr/merges","archive_url":"https://api.github.com/repos/kellym/lint-my-pr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kellym/lint-my-pr/downloads","issues_url":"https://api.github.com/repos/kellym/lint-my-pr/issues{/number}","pulls_url":"https://api.github.com/repos/kellym/lint-my-pr/pulls{/number}","milestones_url":"https://api.github.com/repos/kellym/lint-my-pr/milestones{/number}","notifications_url":"https://api.github.com/repos/kellym/lint-my-pr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kellym/lint-my-pr/labels{/name}","releases_url":"https://api.github.com/repos/kellym/lint-my-pr/releases{/id}","deployments_url":"https://api.github.com/repos/kellym/lint-my-pr/deployments","created_at":"2018-12-13T05:16:53Z","updated_at":"2018-12-13T15:52:45Z","pushed_at":"2018-12-13T15:54:29Z","git_url":"git://github.com/kellym/lint-my-pr.git","ssh_url":"git@github.com:kellym/lint-my-pr.git","clone_url":"https://github.com/kellym/lint-my-pr.git","svn_url":"https://github.com/kellym/lint-my-pr","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1"},"html":{"href":"https://github.com/kellym/lint-my-pr/pull/1"},"issue":{"href":"https://api.github.com/repos/kellym/lint-my-pr/issues/1"},"comments":{"href":"https://api.github.com/repos/kellym/lint-my-pr/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/kellym/lint-my-pr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kellym/lint-my-pr/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/kellym/lint-my-pr/statuses/22090d2a4343c75927b2531ee5a6855a65cdc04c"}},"author_association":"OWNER"}}
{"actor":{"display_login":"kellym"}}