{"action":"opened","number":83,"pull_request":{"url":"https://api.github.com/repos/facebook/jscodeshift/pulls/83","id":54922714,"html_url":"https://github.com/facebook/jscodeshift/pull/83","diff_url":"https://github.com/facebook/jscodeshift/pull/83.diff","patch_url":"https://github.com/facebook/jscodeshift/pull/83.patch","issue_url":"https://api.github.com/repos/facebook/jscodeshift/issues/83","number":83,"state":"open","locked":false,"title":"Fix `Collection.closest`","user":{"login":"juliankrispel","id":1188186,"avatar_url":"https://avatars.githubusercontent.com/u/1188186?v=3","gravatar_id":"","url":"https://api.github.com/users/juliankrispel","html_url":"https://github.com/juliankrispel","followers_url":"https://api.github.com/users/juliankrispel/followers","following_url":"https://api.github.com/users/juliankrispel/following{/other_user}","gists_url":"https://api.github.com/users/juliankrispel/gists{/gist_id}","starred_url":"https://api.github.com/users/juliankrispel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliankrispel/subscriptions","organizations_url":"https://api.github.com/users/juliankrispel/orgs","repos_url":"https://api.github.com/users/juliankrispel/repos","events_url":"https://api.github.com/users/juliankrispel/events{/privacy}","received_events_url":"https://api.github.com/users/juliankrispel/received_events","type":"User","site_admin":false},"body":"At the moment `Collection.closest` doesn't actually work with filters. If `type.check(parent.value)` in the while [loop on line 80](https://github.com/facebook/jscodeshift/blob/master/src/collections/Node.js#L80) returns `true` it will stop the while loop, skipping the last expression, which tests if the filter condition applies.\r\n\r\nThis pr fixes this and refactors the while loop into a recursive function which is imo more readable.\r\n\r\nI also added some specs to prove that closest is working correctly.","created_at":"2016-01-03T10:53:02Z","updated_at":"2016-01-03T10:53:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/83/commits","review_comments_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/83/comments","review_comment_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/jscodeshift/issues/83/comments","statuses_url":"https://api.github.com/repos/facebook/jscodeshift/statuses/c03096e6a4ef7fb1e79256985ea98271d348389e","head":{"label":"juliankrispel:closest","ref":"closest","sha":"c03096e6a4ef7fb1e79256985ea98271d348389e","user":{"login":"juliankrispel","id":1188186,"avatar_url":"https://avatars.githubusercontent.com/u/1188186?v=3","gravatar_id":"","url":"https://api.github.com/users/juliankrispel","html_url":"https://github.com/juliankrispel","followers_url":"https://api.github.com/users/juliankrispel/followers","following_url":"https://api.github.com/users/juliankrispel/following{/other_user}","gists_url":"https://api.github.com/users/juliankrispel/gists{/gist_id}","starred_url":"https://api.github.com/users/juliankrispel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliankrispel/subscriptions","organizations_url":"https://api.github.com/users/juliankrispel/orgs","repos_url":"https://api.github.com/users/juliankrispel/repos","events_url":"https://api.github.com/users/juliankrispel/events{/privacy}","received_events_url":"https://api.github.com/users/juliankrispel/received_events","type":"User","site_admin":false},"repo":{"id":48939877,"name":"jscodeshift","full_name":"juliankrispel/jscodeshift","owner":{"login":"juliankrispel","id":1188186,"avatar_url":"https://avatars.githubusercontent.com/u/1188186?v=3","gravatar_id":"","url":"https://api.github.com/users/juliankrispel","html_url":"https://github.com/juliankrispel","followers_url":"https://api.github.com/users/juliankrispel/followers","following_url":"https://api.github.com/users/juliankrispel/following{/other_user}","gists_url":"https://api.github.com/users/juliankrispel/gists{/gist_id}","starred_url":"https://api.github.com/users/juliankrispel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliankrispel/subscriptions","organizations_url":"https://api.github.com/users/juliankrispel/orgs","repos_url":"https://api.github.com/users/juliankrispel/repos","events_url":"https://api.github.com/users/juliankrispel/events{/privacy}","received_events_url":"https://api.github.com/users/juliankrispel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/juliankrispel/jscodeshift","description":"A JavaScript codemod toolkit.","fork":true,"url":"https://api.github.com/repos/juliankrispel/jscodeshift","forks_url":"https://api.github.com/repos/juliankrispel/jscodeshift/forks","keys_url":"https://api.github.com/repos/juliankrispel/jscodeshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juliankrispel/jscodeshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juliankrispel/jscodeshift/teams","hooks_url":"https://api.github.com/repos/juliankrispel/jscodeshift/hooks","issue_events_url":"https://api.github.com/repos/juliankrispel/jscodeshift/issues/events{/number}","events_url":"https://api.github.com/repos/juliankrispel/jscodeshift/events","assignees_url":"https://api.github.com/repos/juliankrispel/jscodeshift/assignees{/user}","branches_url":"https://api.github.com/repos/juliankrispel/jscodeshift/branches{/branch}","tags_url":"https://api.github.com/repos/juliankrispel/jscodeshift/tags","blobs_url":"https://api.github.com/repos/juliankrispel/jscodeshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juliankrispel/jscodeshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juliankrispel/jscodeshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/juliankrispel/jscodeshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juliankrispel/jscodeshift/statuses/{sha}","languages_url":"https://api.github.com/repos/juliankrispel/jscodeshift/languages","stargazers_url":"https://api.github.com/repos/juliankrispel/jscodeshift/stargazers","contributors_url":"https://api.github.com/repos/juliankrispel/jscodeshift/contributors","subscribers_url":"https://api.github.com/repos/juliankrispel/jscodeshift/subscribers","subscription_url":"https://api.github.com/repos/juliankrispel/jscodeshift/subscription","commits_url":"https://api.github.com/repos/juliankrispel/jscodeshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/juliankrispel/jscodeshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/juliankrispel/jscodeshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/juliankrispel/jscodeshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/juliankrispel/jscodeshift/contents/{+path}","compare_url":"https://api.github.com/repos/juliankrispel/jscodeshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juliankrispel/jscodeshift/merges","archive_url":"https://api.github.com/repos/juliankrispel/jscodeshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juliankrispel/jscodeshift/downloads","issues_url":"https://api.github.com/repos/juliankrispel/jscodeshift/issues{/number}","pulls_url":"https://api.github.com/repos/juliankrispel/jscodeshift/pulls{/number}","milestones_url":"https://api.github.com/repos/juliankrispel/jscodeshift/milestones{/number}","notifications_url":"https://api.github.com/repos/juliankrispel/jscodeshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juliankrispel/jscodeshift/labels{/name}","releases_url":"https://api.github.com/repos/juliankrispel/jscodeshift/releases{/id}","created_at":"2016-01-03T08:59:42Z","updated_at":"2016-01-03T08:59:42Z","pushed_at":"2016-01-03T10:52:11Z","git_url":"git://github.com/juliankrispel/jscodeshift.git","ssh_url":"git@github.com:juliankrispel/jscodeshift.git","clone_url":"https://github.com/juliankrispel/jscodeshift.git","svn_url":"https://github.com/juliankrispel/jscodeshift","homepage":"","size":94,"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":"facebook:master","ref":"master","sha":"f70fdaa94b6f0f51012f7273153c8194e4dd0755","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":31795422,"name":"jscodeshift","full_name":"facebook/jscodeshift","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/jscodeshift","description":"A JavaScript codemod toolkit.","fork":false,"url":"https://api.github.com/repos/facebook/jscodeshift","forks_url":"https://api.github.com/repos/facebook/jscodeshift/forks","keys_url":"https://api.github.com/repos/facebook/jscodeshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/jscodeshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/jscodeshift/teams","hooks_url":"https://api.github.com/repos/facebook/jscodeshift/hooks","issue_events_url":"https://api.github.com/repos/facebook/jscodeshift/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/jscodeshift/events","assignees_url":"https://api.github.com/repos/facebook/jscodeshift/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/jscodeshift/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/jscodeshift/tags","blobs_url":"https://api.github.com/repos/facebook/jscodeshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/jscodeshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/jscodeshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/jscodeshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/jscodeshift/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/jscodeshift/languages","stargazers_url":"https://api.github.com/repos/facebook/jscodeshift/stargazers","contributors_url":"https://api.github.com/repos/facebook/jscodeshift/contributors","subscribers_url":"https://api.github.com/repos/facebook/jscodeshift/subscribers","subscription_url":"https://api.github.com/repos/facebook/jscodeshift/subscription","commits_url":"https://api.github.com/repos/facebook/jscodeshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/jscodeshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/jscodeshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/jscodeshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/jscodeshift/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/jscodeshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/jscodeshift/merges","archive_url":"https://api.github.com/repos/facebook/jscodeshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/jscodeshift/downloads","issues_url":"https://api.github.com/repos/facebook/jscodeshift/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/jscodeshift/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/jscodeshift/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/jscodeshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/jscodeshift/labels{/name}","releases_url":"https://api.github.com/repos/facebook/jscodeshift/releases{/id}","created_at":"2015-03-07T00:32:16Z","updated_at":"2016-01-02T13:01:53Z","pushed_at":"2015-12-19T12:24:59Z","git_url":"git://github.com/facebook/jscodeshift.git","ssh_url":"git@github.com:facebook/jscodeshift.git","clone_url":"https://github.com/facebook/jscodeshift.git","svn_url":"https://github.com/facebook/jscodeshift","homepage":"","size":130,"stargazers_count":476,"watchers_count":476,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":27,"forks":32,"open_issues":27,"watchers":476,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/83"},"html":{"href":"https://github.com/facebook/jscodeshift/pull/83"},"issue":{"href":"https://api.github.com/repos/facebook/jscodeshift/issues/83"},"comments":{"href":"https://api.github.com/repos/facebook/jscodeshift/issues/83/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/83/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/83/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/jscodeshift/statuses/c03096e6a4ef7fb1e79256985ea98271d348389e"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":4,"additions":64,"deletions":22,"changed_files":2}}