GitHub PullRequestReviewCommentEvent at 2014-02-01 16:51:58
Repository: eslint
Actor: nzakas
Payload: {"comment":{"url":"https://api.github.com/repos/eslint/eslint/pulls/comments/9366221","id":9366221,"diff_hunk":"@@ -0,0 +1,29 @@\n+/**\n+ * @fileoverview Rule to flag blocks with no reason to exist\n+ * @author Brandon Mills\n+ */\n+\n+//------------------------------------------------------------------------------\n+// Rule Definition\n+//------------------------------------------------------------------------------\n+\n+module.exports = function(context) {\n+\n+    \"use strict\";\n+\n+    function checkForLoners(node) {\n+        // Check for any occurrence of BlockStatement > BlockStatement or\n+        // Program > BlockStatement\n+        node.body.forEach(function (stmt) {","path":"lib/rules/no-lone-blocks.js","position":17,"original_position":17,"commit_id":"7b2187451dba43c31849f72fc00fef7419720a37","original_commit_id":"7b2187451dba43c31849f72fc00fef7419720a37","user":{"login":"nzakas","id":38546,"avatar_url":"https://gravatar.com/avatar/b605f11383e1ec18717bca5a5c36ee15?d=https%3A%2F%2Fidenticons.github.com%2F7521b1aabd1f65a32347dfcb0676a3c5.png&r=x","gravatar_id":"b605f11383e1ec18717bca5a5c36ee15","url":"https://api.github.com/users/nzakas","html_url":"https://github.com/nzakas","followers_url":"https://api.github.com/users/nzakas/followers","following_url":"https://api.github.com/users/nzakas/following{/other_user}","gists_url":"https://api.github.com/users/nzakas/gists{/gist_id}","starred_url":"https://api.github.com/users/nzakas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nzakas/subscriptions","organizations_url":"https://api.github.com/users/nzakas/orgs","repos_url":"https://api.github.com/users/nzakas/repos","events_url":"https://api.github.com/users/nzakas/events{/privacy}","received_events_url":"https://api.github.com/users/nzakas/received_events","type":"User","site_admin":false},"body":"To add to @michaelficarra, ESLint already does a traversal down, so doing another traversal down inside of a rule is wasteful. You can listen for \"BlockStatement\", then use `context.getAncenstors()` to check the parent.","created_at":"2014-02-01T16:51:58Z","updated_at":"2014-02-01T16:51:58Z","html_url":"https://github.com/eslint/eslint/pull/572#discussion_r9366221","pull_request_url":"https://api.github.com/repos/eslint/eslint/pulls/572","_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments/9366221"},"html":{"href":"https://github.com/eslint/eslint/pull/572#discussion_r9366221"},"pull_request":{"href":"https://api.github.com/repos/eslint/eslint/pulls/572"}}}}