{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/6665","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/6665/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/6665/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/6665/events","html_url":"https://github.com/eslint/eslint/issues/6665","id":165369283,"number":6665,"title":"Add option to only prefer-arrow-callback on single statement functions","user":{"login":"NickHeiner","id":829827,"avatar_url":"https://avatars.githubusercontent.com/u/829827?v=3","gravatar_id":"","url":"https://api.github.com/users/NickHeiner","html_url":"https://github.com/NickHeiner","followers_url":"https://api.github.com/users/NickHeiner/followers","following_url":"https://api.github.com/users/NickHeiner/following{/other_user}","gists_url":"https://api.github.com/users/NickHeiner/gists{/gist_id}","starred_url":"https://api.github.com/users/NickHeiner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NickHeiner/subscriptions","organizations_url":"https://api.github.com/users/NickHeiner/orgs","repos_url":"https://api.github.com/users/NickHeiner/repos","events_url":"https://api.github.com/users/NickHeiner/events{/privacy}","received_events_url":"https://api.github.com/users/NickHeiner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/eslint/eslint/labels/evaluating","name":"evaluating","color":"fef2c0"},{"url":"https://api.github.com/repos/eslint/eslint/labels/rule","name":"rule","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-13T16:50:42Z","updated_at":"2016-07-13T19:34:30Z","closed_at":null,"body":"I would like to have a lint rule that only requires single statement functions to use the arrow callback style:\r\n\r\n```js\r\n// ok\r\nfoo(function() {\r\n    console.log('x');\r\n    return y;\r\n});\r\n\r\n// not ok\r\nfoo(function() {\r\n    return y;\r\n});\r\n\r\n// corrected\r\nfoo(() => y);\r\n```\r\n\r\nRight now, there is no way to express this with the eslint rules as far as I can tell.\r\n\r\nI would add this as an option to `prefer-arrow-callback`. Something like:\r\n\r\n```\r\n'prefer-arrow-callback': ['warn', {allowMultiStatementFunctions: true}],\r\n```\r\n\r\nI am currently using `eslint@3.0.1` and `Node v.4.2.1`. I'm happy to submit a PR for this if you'd accept it. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/232462609","html_url":"https://github.com/eslint/eslint/issues/6665#issuecomment-232462609","issue_url":"https://api.github.com/repos/eslint/eslint/issues/6665","id":232462609,"user":{"login":"platinumazure","id":284282,"avatar_url":"https://avatars.githubusercontent.com/u/284282?v=3","gravatar_id":"","url":"https://api.github.com/users/platinumazure","html_url":"https://github.com/platinumazure","followers_url":"https://api.github.com/users/platinumazure/followers","following_url":"https://api.github.com/users/platinumazure/following{/other_user}","gists_url":"https://api.github.com/users/platinumazure/gists{/gist_id}","starred_url":"https://api.github.com/users/platinumazure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/platinumazure/subscriptions","organizations_url":"https://api.github.com/users/platinumazure/orgs","repos_url":"https://api.github.com/users/platinumazure/repos","events_url":"https://api.github.com/users/platinumazure/events{/privacy}","received_events_url":"https://api.github.com/users/platinumazure/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T19:34:29Z","updated_at":"2016-07-13T19:34:29Z","body":"Hi @NickHeiner, thanks for the issue! I agree this seems like a worthwhile enhancement, though I wonder if it could generalize to \"require arrow functions if statement count is <= some number\"?\r\n\r\nI've gone ahead and filled out the [rule change request questionnaire](http://eslint.org/docs/developer-guide/contributing/rule-changes#proposing-a-rule-change) for you, please let me know if I've gotten anything wrong. (And in future, please do consider using this as a guideline for rule change requests, it really helps us out!)\r\n\r\n## The version of ESLint you are using\r\nESLint 3.0.1\r\n\r\n## The rule you want to change\r\nprefer-arrow-callback\r\n\r\n## The code you want to be flagged as ~~incorrect~~ correct\r\n```js\r\nfoo(function () {\r\n    console.log('x');\r\n    return y;\r\n});\r\n```\r\n\r\nNo change requested for functions of one statement in length:\r\n```js\r\nfoo(function() {\r\n    return y;    // Is flagged, should still be flagged\r\n});\r\n```\r\n\r\n## What happens when the rule is applied to the code without your change\r\nFirst example shows an error requiring an arrow callback. Second example correctly shows an error (and no change is desired)."}}
{"actor":{"display_login":"platinumazure"}}