{"action":"opened","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/2242","labels_url":"https://api.github.com/repos/eslint/eslint/issues/2242/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/2242/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/2242/events","html_url":"https://github.com/eslint/eslint/issues/2242","id":66681193,"number":2242,"title":"block-scoped-var: function id in the wrong scope","user":{"login":"Cellule","id":4157103,"avatar_url":"https://avatars.githubusercontent.com/u/4157103?v=3","gravatar_id":"","url":"https://api.github.com/users/Cellule","html_url":"https://github.com/Cellule","followers_url":"https://api.github.com/users/Cellule/followers","following_url":"https://api.github.com/users/Cellule/following{/other_user}","gists_url":"https://api.github.com/users/Cellule/gists{/gist_id}","starred_url":"https://api.github.com/users/Cellule/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cellule/subscriptions","organizations_url":"https://api.github.com/users/Cellule/orgs","repos_url":"https://api.github.com/users/Cellule/repos","events_url":"https://api.github.com/users/Cellule/events{/privacy}","received_events_url":"https://api.github.com/users/Cellule/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-06T19:07:19Z","updated_at":"2015-04-06T19:07:19Z","closed_at":null,"body":"I have a simple test case:\r\n```\r\nfunction foo() {\r\n  console.log(\"bar\");\r\n}\r\nfoo();\r\nmodule.exports = {\r\n  foo: foo\r\n};\r\n```\r\nThat gives me the errors\r\n```\r\n  4:0  error  \"foo\" used outside of binding context  block-scoped-var\r\n  6:7  error  \"foo\" used outside of binding context  block-scoped-var\r\n```\r\nBy looking at the rules, I found that the identifier for the function is declared in the scope of the function and not its parent. Which means the function appears to be used in the wrong scope.\r\n\r\nI could fix the issue simply by declaring the function id before pushing the scope at\r\nhttps://github.com/eslint/eslint/blob/master/lib/rules/block-scoped-var.js#L176\r\n\r\nI haven't tested yet to see if this breaks anything else yet, but I will look into it."}}