{"action":"created","issue":{"url":"https://api.github.com/repos/feross/standard/issues/510","repository_url":"https://api.github.com/repos/feross/standard","labels_url":"https://api.github.com/repos/feross/standard/issues/510/labels{/name}","comments_url":"https://api.github.com/repos/feross/standard/issues/510/comments","events_url":"https://api.github.com/repos/feross/standard/issues/510/events","html_url":"https://github.com/feross/standard/issues/510","id":152984630,"number":510,"title":"using `return` in the top level of a node.js script","user":{"login":"75lb","id":1247980,"avatar_url":"https://avatars.githubusercontent.com/u/1247980?v=3","gravatar_id":"","url":"https://api.github.com/users/75lb","html_url":"https://github.com/75lb","followers_url":"https://api.github.com/users/75lb/followers","following_url":"https://api.github.com/users/75lb/following{/other_user}","gists_url":"https://api.github.com/users/75lb/gists{/gist_id}","starred_url":"https://api.github.com/users/75lb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/75lb/subscriptions","organizations_url":"https://api.github.com/users/75lb/orgs","repos_url":"https://api.github.com/users/75lb/repos","events_url":"https://api.github.com/users/75lb/events{/privacy}","received_events_url":"https://api.github.com/users/75lb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-04T10:59:55Z","updated_at":"2016-05-04T12:20:23Z","closed_at":"2016-05-04T12:20:23Z","body":"using standard v7, trying to validate this node.js script:\r\n```\r\nconsole.log('one')\r\nreturn \r\nconsole.log('two')\r\n```\r\n\r\nthrows this issue:\r\n```\r\nParsing error: 'return' outside of function\r\n```\r\n\r\nIn node.js, the top level script is [wrapped by a function](http://stackoverflow.com/questions/28955047/why-does-a-module-level-return-statement-work-in-node-js). Even though it might *look* like use of `return` outside a function, it is not.. \r\n\r\nwhat to do here? This is a valid use of `return`.. "},"comment":{"url":"https://api.github.com/repos/feross/standard/issues/comments/216843261","html_url":"https://github.com/feross/standard/issues/510#issuecomment-216843261","issue_url":"https://api.github.com/repos/feross/standard/issues/510","id":216843261,"user":{"login":"feross","id":121766,"avatar_url":"https://avatars.githubusercontent.com/u/121766?v=3","gravatar_id":"","url":"https://api.github.com/users/feross","html_url":"https://github.com/feross","followers_url":"https://api.github.com/users/feross/followers","following_url":"https://api.github.com/users/feross/following{/other_user}","gists_url":"https://api.github.com/users/feross/gists{/gist_id}","starred_url":"https://api.github.com/users/feross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feross/subscriptions","organizations_url":"https://api.github.com/users/feross/orgs","repos_url":"https://api.github.com/users/feross/repos","events_url":"https://api.github.com/users/feross/events{/privacy}","received_events_url":"https://api.github.com/users/feross/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T12:20:23Z","updated_at":"2016-05-04T12:20:23Z","body":"Yes, this has been an issue for a long time.\r\n\r\nThis is an unfortunate side effect of two bad decisions made by TC39:\r\n\r\n1. Top-level return is an error.\r\n2. ES modules have a completely different parsing mode (\"module\") than the normal mode (\"script\").\r\n\r\nThe decision to have two modes means that every piece of tooling that parses JS has to expose this decision to the user.\r\n\r\nTo keep `standard` simple, we just assume \"module\" which makes the ESLint parser support all the module syntax (`export`, etc.) but has the downside of preventing top-level return. :(\r\n\r\nIf we assumed \"script\" then many more things would not work, so this is the right compromise I think."}}