{"action":"created","comment":{"url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/comments/61135809","id":61135809,"diff_hunk":"@@ -0,0 +1,52 @@\n+/**\n+ * @fileoverview Rule to enforce new line after import not followed by another import.\n+ * @author Radek Benkel\n+ */\n+\n+//------------------------------------------------------------------------------\n+// Rule Definition\n+//------------------------------------------------------------------------------\n+\n+function getLineDifference(node, nextToken) {\n+  return nextToken.loc.start.line - node.loc.start.line\n+}\n+\n+function ensureNoForbiddenKeyword(context, node, tokenToInspect, tokenValue) {\n+  if (getLineDifference(node, tokenToInspect) === 1\n+    && tokenToInspect.type === 'Keyword' && tokenToInspect.value !== tokenValue)\n+  {\n+    context.report({\n+      loc: tokenToInspect.loc.start,\n+      message: 'Expected empty line after import/require ' +\n+        'statement not followed by another import.',\n+    })\n+  }\n+}\n+\n+module.exports = function (context) {\n+  return {\n+    ImportDeclaration: function (node) {\n+      const nextToken = context.getSourceCode(node).getTokenAfter(node)\n+\n+      if (!nextToken) {\n+        return\n+      }\n+\n+      ensureNoForbiddenKeyword(context, node, nextToken, 'import')\n+    },\n+    CallExpression: function(node) {\n+      if (node.callee.name === \"require\") {\n+        const nextTokens = context.getSourceCode(node).getTokensAfter(node, 2)\n+        const tokenToInspect = nextTokens.length > 1 && nextTokens[0].type === 'Punctuator'\n+          ? nextTokens[1]\n+          : nextTokens[0]\n+\n+        if (!tokenToInspect) {\n+          return\n+        }","path":"src/rules/newline-after-import.js","position":46,"original_position":46,"commit_id":"4414177e3083d351127f26b9b4569b8f872b927a","original_commit_id":"4414177e3083d351127f26b9b4569b8f872b927a","user":{"login":"jfmengels","id":3869412,"avatar_url":"https://avatars.githubusercontent.com/u/3869412?v=3","gravatar_id":"","url":"https://api.github.com/users/jfmengels","html_url":"https://github.com/jfmengels","followers_url":"https://api.github.com/users/jfmengels/followers","following_url":"https://api.github.com/users/jfmengels/following{/other_user}","gists_url":"https://api.github.com/users/jfmengels/gists{/gist_id}","starred_url":"https://api.github.com/users/jfmengels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfmengels/subscriptions","organizations_url":"https://api.github.com/users/jfmengels/orgs","repos_url":"https://api.github.com/users/jfmengels/repos","events_url":"https://api.github.com/users/jfmengels/events{/privacy}","received_events_url":"https://api.github.com/users/jfmengels/received_events","type":"User","site_admin":false},"body":"You could move this check to `ensureNoForbiddenKeyword` for both `import` and `require` cases.","created_at":"2016-04-26T18:10:10Z","updated_at":"2016-04-26T18:10:10Z","html_url":"https://github.com/benmosher/eslint-plugin-import/pull/245#discussion_r61135809","pull_request_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245","_links":{"self":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/comments/61135809"},"html":{"href":"https://github.com/benmosher/eslint-plugin-import/pull/245#discussion_r61135809"},"pull_request":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245"}}},"pull_request":{"url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245","id":66849243,"html_url":"https://github.com/benmosher/eslint-plugin-import/pull/245","diff_url":"https://github.com/benmosher/eslint-plugin-import/pull/245.diff","patch_url":"https://github.com/benmosher/eslint-plugin-import/pull/245.patch","issue_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues/245","number":245,"state":"open","locked":false,"title":"Add `newline-after-import` rule","user":{"login":"singles","id":218345,"avatar_url":"https://avatars.githubusercontent.com/u/218345?v=3","gravatar_id":"","url":"https://api.github.com/users/singles","html_url":"https://github.com/singles","followers_url":"https://api.github.com/users/singles/followers","following_url":"https://api.github.com/users/singles/following{/other_user}","gists_url":"https://api.github.com/users/singles/gists{/gist_id}","starred_url":"https://api.github.com/users/singles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singles/subscriptions","organizations_url":"https://api.github.com/users/singles/orgs","repos_url":"https://api.github.com/users/singles/repos","events_url":"https://api.github.com/users/singles/events{/privacy}","received_events_url":"https://api.github.com/users/singles/received_events","type":"User","site_admin":false},"body":"# newline-after-import (#244)\r\n\r\nReports if there's no new line after last import in group.\r\n\r\n## Rule Details\r\n\r\nValid:\r\n\r\n```js\r\nimport defaultExport from './foo'\r\n\r\nconst FOO = 'BAR'\r\n```\r\n\r\n```js\r\nimport defaultExport from './foo'\r\nimport { bar }  from 'bar-lib'\r\n\r\nconst FOO = 'BAR'\r\n```\r\n\r\n...whereas here imports will be reported:\r\n\r\n```js\r\nimport * as foo from 'foo'\r\nconst FOO = 'BAR'\r\n```\r\n\r\n```js\r\nimport * as foo from 'foo'\r\nconst FOO = 'BAR'\r\n\r\nimport { bar }  from 'bar-lib'\r\n```\r\n\r\n## When Not To Use It\r\n\r\nIf you like to visually group module imports with its usage, you don't want to use this rule.","created_at":"2016-04-18T13:02:40Z","updated_at":"2016-04-26T18:10:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"afc4e75a67da11442278195329dab6316bcecfcd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245/commits","review_comments_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245/comments","review_comment_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/comments{/number}","comments_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues/245/comments","statuses_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/statuses/4414177e3083d351127f26b9b4569b8f872b927a","head":{"label":"singles:new-rule-newline-after-imports","ref":"new-rule-newline-after-imports","sha":"4414177e3083d351127f26b9b4569b8f872b927a","user":{"login":"singles","id":218345,"avatar_url":"https://avatars.githubusercontent.com/u/218345?v=3","gravatar_id":"","url":"https://api.github.com/users/singles","html_url":"https://github.com/singles","followers_url":"https://api.github.com/users/singles/followers","following_url":"https://api.github.com/users/singles/following{/other_user}","gists_url":"https://api.github.com/users/singles/gists{/gist_id}","starred_url":"https://api.github.com/users/singles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singles/subscriptions","organizations_url":"https://api.github.com/users/singles/orgs","repos_url":"https://api.github.com/users/singles/repos","events_url":"https://api.github.com/users/singles/events{/privacy}","received_events_url":"https://api.github.com/users/singles/received_events","type":"User","site_admin":false},"repo":{"id":55622315,"name":"eslint-plugin-import","full_name":"singles/eslint-plugin-import","owner":{"login":"singles","id":218345,"avatar_url":"https://avatars.githubusercontent.com/u/218345?v=3","gravatar_id":"","url":"https://api.github.com/users/singles","html_url":"https://github.com/singles","followers_url":"https://api.github.com/users/singles/followers","following_url":"https://api.github.com/users/singles/following{/other_user}","gists_url":"https://api.github.com/users/singles/gists{/gist_id}","starred_url":"https://api.github.com/users/singles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singles/subscriptions","organizations_url":"https://api.github.com/users/singles/orgs","repos_url":"https://api.github.com/users/singles/repos","events_url":"https://api.github.com/users/singles/events{/privacy}","received_events_url":"https://api.github.com/users/singles/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/singles/eslint-plugin-import","description":"ESLint plugin with rules that help validate proper imports.","fork":true,"url":"https://api.github.com/repos/singles/eslint-plugin-import","forks_url":"https://api.github.com/repos/singles/eslint-plugin-import/forks","keys_url":"https://api.github.com/repos/singles/eslint-plugin-import/keys{/key_id}","collaborators_url":"https://api.github.com/repos/singles/eslint-plugin-import/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/singles/eslint-plugin-import/teams","hooks_url":"https://api.github.com/repos/singles/eslint-plugin-import/hooks","issue_events_url":"https://api.github.com/repos/singles/eslint-plugin-import/issues/events{/number}","events_url":"https://api.github.com/repos/singles/eslint-plugin-import/events","assignees_url":"https://api.github.com/repos/singles/eslint-plugin-import/assignees{/user}","branches_url":"https://api.github.com/repos/singles/eslint-plugin-import/branches{/branch}","tags_url":"https://api.github.com/repos/singles/eslint-plugin-import/tags","blobs_url":"https://api.github.com/repos/singles/eslint-plugin-import/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/singles/eslint-plugin-import/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/singles/eslint-plugin-import/git/refs{/sha}","trees_url":"https://api.github.com/repos/singles/eslint-plugin-import/git/trees{/sha}","statuses_url":"https://api.github.com/repos/singles/eslint-plugin-import/statuses/{sha}","languages_url":"https://api.github.com/repos/singles/eslint-plugin-import/languages","stargazers_url":"https://api.github.com/repos/singles/eslint-plugin-import/stargazers","contributors_url":"https://api.github.com/repos/singles/eslint-plugin-import/contributors","subscribers_url":"https://api.github.com/repos/singles/eslint-plugin-import/subscribers","subscription_url":"https://api.github.com/repos/singles/eslint-plugin-import/subscription","commits_url":"https://api.github.com/repos/singles/eslint-plugin-import/commits{/sha}","git_commits_url":"https://api.github.com/repos/singles/eslint-plugin-import/git/commits{/sha}","comments_url":"https://api.github.com/repos/singles/eslint-plugin-import/comments{/number}","issue_comment_url":"https://api.github.com/repos/singles/eslint-plugin-import/issues/comments{/number}","contents_url":"https://api.github.com/repos/singles/eslint-plugin-import/contents/{+path}","compare_url":"https://api.github.com/repos/singles/eslint-plugin-import/compare/{base}...{head}","merges_url":"https://api.github.com/repos/singles/eslint-plugin-import/merges","archive_url":"https://api.github.com/repos/singles/eslint-plugin-import/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/singles/eslint-plugin-import/downloads","issues_url":"https://api.github.com/repos/singles/eslint-plugin-import/issues{/number}","pulls_url":"https://api.github.com/repos/singles/eslint-plugin-import/pulls{/number}","milestones_url":"https://api.github.com/repos/singles/eslint-plugin-import/milestones{/number}","notifications_url":"https://api.github.com/repos/singles/eslint-plugin-import/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/singles/eslint-plugin-import/labels{/name}","releases_url":"https://api.github.com/repos/singles/eslint-plugin-import/releases{/id}","deployments_url":"https://api.github.com/repos/singles/eslint-plugin-import/deployments","created_at":"2016-04-06T16:28:53Z","updated_at":"2016-04-06T16:28:54Z","pushed_at":"2016-04-26T16:55:08Z","git_url":"git://github.com/singles/eslint-plugin-import.git","ssh_url":"git@github.com:singles/eslint-plugin-import.git","clone_url":"https://github.com/singles/eslint-plugin-import.git","svn_url":"https://github.com/singles/eslint-plugin-import","homepage":null,"size":606,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"benmosher:master","ref":"master","sha":"ea1b0e3d2d0c58287d8513a71e79100b48feed38","user":{"login":"benmosher","id":3709196,"avatar_url":"https://avatars.githubusercontent.com/u/3709196?v=3","gravatar_id":"","url":"https://api.github.com/users/benmosher","html_url":"https://github.com/benmosher","followers_url":"https://api.github.com/users/benmosher/followers","following_url":"https://api.github.com/users/benmosher/following{/other_user}","gists_url":"https://api.github.com/users/benmosher/gists{/gist_id}","starred_url":"https://api.github.com/users/benmosher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benmosher/subscriptions","organizations_url":"https://api.github.com/users/benmosher/orgs","repos_url":"https://api.github.com/users/benmosher/repos","events_url":"https://api.github.com/users/benmosher/events{/privacy}","received_events_url":"https://api.github.com/users/benmosher/received_events","type":"User","site_admin":false},"repo":{"id":32238354,"name":"eslint-plugin-import","full_name":"benmosher/eslint-plugin-import","owner":{"login":"benmosher","id":3709196,"avatar_url":"https://avatars.githubusercontent.com/u/3709196?v=3","gravatar_id":"","url":"https://api.github.com/users/benmosher","html_url":"https://github.com/benmosher","followers_url":"https://api.github.com/users/benmosher/followers","following_url":"https://api.github.com/users/benmosher/following{/other_user}","gists_url":"https://api.github.com/users/benmosher/gists{/gist_id}","starred_url":"https://api.github.com/users/benmosher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benmosher/subscriptions","organizations_url":"https://api.github.com/users/benmosher/orgs","repos_url":"https://api.github.com/users/benmosher/repos","events_url":"https://api.github.com/users/benmosher/events{/privacy}","received_events_url":"https://api.github.com/users/benmosher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benmosher/eslint-plugin-import","description":"ESLint plugin with rules that help validate proper imports.","fork":false,"url":"https://api.github.com/repos/benmosher/eslint-plugin-import","forks_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/forks","keys_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/teams","hooks_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/hooks","issue_events_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues/events{/number}","events_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/events","assignees_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/assignees{/user}","branches_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/branches{/branch}","tags_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/tags","blobs_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/git/refs{/sha}","trees_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/statuses/{sha}","languages_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/languages","stargazers_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/stargazers","contributors_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/contributors","subscribers_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/subscribers","subscription_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/subscription","commits_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/commits{/sha}","git_commits_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/git/commits{/sha}","comments_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/comments{/number}","issue_comment_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues/comments{/number}","contents_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/contents/{+path}","compare_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/merges","archive_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/downloads","issues_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues{/number}","pulls_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls{/number}","milestones_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/milestones{/number}","notifications_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/labels{/name}","releases_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/releases{/id}","deployments_url":"https://api.github.com/repos/benmosher/eslint-plugin-import/deployments","created_at":"2015-03-15T00:21:57Z","updated_at":"2016-04-26T13:19:47Z","pushed_at":"2016-04-26T16:56:08Z","git_url":"git://github.com/benmosher/eslint-plugin-import.git","ssh_url":"git@github.com:benmosher/eslint-plugin-import.git","clone_url":"https://github.com/benmosher/eslint-plugin-import.git","svn_url":"https://github.com/benmosher/eslint-plugin-import","homepage":null,"size":634,"stargazers_count":208,"watchers_count":208,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":41,"forks":26,"open_issues":41,"watchers":208,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245"},"html":{"href":"https://github.com/benmosher/eslint-plugin-import/pull/245"},"issue":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues/245"},"comments":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/issues/245/comments"},"review_comments":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245/comments"},"review_comment":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/pulls/245/commits"},"statuses":{"href":"https://api.github.com/repos/benmosher/eslint-plugin-import/statuses/4414177e3083d351127f26b9b4569b8f872b927a"}}}}