{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/5982","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/5982/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/5982/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/5982/events","html_url":"https://github.com/eslint/eslint/issues/5982","id":151397549,"number":5982,"title":"New rule: newline-before-if","user":{"login":"fiolkaf","id":6086938,"avatar_url":"https://avatars.githubusercontent.com/u/6086938?v=3","gravatar_id":"","url":"https://api.github.com/users/fiolkaf","html_url":"https://github.com/fiolkaf","followers_url":"https://api.github.com/users/fiolkaf/followers","following_url":"https://api.github.com/users/fiolkaf/following{/other_user}","gists_url":"https://api.github.com/users/fiolkaf/gists{/gist_id}","starred_url":"https://api.github.com/users/fiolkaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiolkaf/subscriptions","organizations_url":"https://api.github.com/users/fiolkaf/orgs","repos_url":"https://api.github.com/users/fiolkaf/repos","events_url":"https://api.github.com/users/fiolkaf/events{/privacy}","received_events_url":"https://api.github.com/users/fiolkaf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/evaluating","name":"evaluating","color":"fef2c0"},{"url":"https://api.github.com/repos/eslint/eslint/labels/feature","name":"feature","color":"bfd4f2"},{"url":"https://api.github.com/repos/eslint/eslint/labels/rule","name":"rule","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/eslint/eslint/milestones/15","html_url":"https://github.com/eslint/eslint/milestones/JSCS%20Compatibility","labels_url":"https://api.github.com/repos/eslint/eslint/milestones/15/labels","id":1707375,"number":15,"title":"JSCS Compatibility","description":"","creator":{"login":"nzakas","id":38546,"avatar_url":"https://avatars.githubusercontent.com/u/38546?v=3","gravatar_id":"","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},"open_issues":12,"closed_issues":1,"state":"open","created_at":"2016-04-14T18:09:38Z","updated_at":"2016-04-27T15:44:54Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2016-04-27T14:17:39Z","updated_at":"2016-05-02T15:35:25Z","closed_at":null,"body":"1. This rule will warn when no newline before if statement.\r\n\r\nCorrect:\r\n```js\r\nconst a = 10;\r\n\r\nif (a === 10) {\r\n}\r\n```\r\n\r\nIncorrect:\r\n```js\r\nconst a = 10;\r\nif (a === 10) {\r\n}\r\n```\r\n\r\n2. This rule is stylistic only.\r\n\r\n3. This rule is can be widely used as it increases code readability.\r\n\r\n4. Yes. I can create rule by myself."},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/216269692","html_url":"https://github.com/eslint/eslint/issues/5982#issuecomment-216269692","issue_url":"https://api.github.com/repos/eslint/eslint/issues/5982","id":216269692,"user":{"login":"mysticatea","id":1937871,"avatar_url":"https://avatars.githubusercontent.com/u/1937871?v=3","gravatar_id":"","url":"https://api.github.com/users/mysticatea","html_url":"https://github.com/mysticatea","followers_url":"https://api.github.com/users/mysticatea/followers","following_url":"https://api.github.com/users/mysticatea/following{/other_user}","gists_url":"https://api.github.com/users/mysticatea/gists{/gist_id}","starred_url":"https://api.github.com/users/mysticatea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysticatea/subscriptions","organizations_url":"https://api.github.com/users/mysticatea/orgs","repos_url":"https://api.github.com/users/mysticatea/repos","events_url":"https://api.github.com/users/mysticatea/events{/privacy}","received_events_url":"https://api.github.com/users/mysticatea/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T15:35:24Z","updated_at":"2016-05-02T15:35:24Z","body":"I think addressing the location of nodes is important for this rule.\r\nEspecially, `FunctionExpression` can locate at many places: object methods, class methods, and etc...\r\n\r\nIn my image, this rule will address bare block statements, block statements with keywords (e.g. if-block, while-block, function-declaration, class-declaration), switch statements.\r\nSo...., my proposal's `lines-around-block` is a mix of a part of [requirePaddingNewlinesBeforeKeywords] and a part of [requirePaddingNewLinesAfterBlocks].\r\nIn my image, [requirePaddingNewlinesBeforeKeywords] and [requirePaddingNewLinesAfterBlocks] are converted to `lines-around-block` and `lines-between-class-members` or something like (#5949).\r\nBut, this customizing of the boundary of rules may cause confusing for JSCS compatibility.\r\n`newline-before-keyword` and `newline-after-block` may be better than my proposal.\r\n\r\n[requirePaddingNewlinesBeforeKeywords]: http://jscs.info/rule/requirePaddingNewlinesBeforeKeywords\r\n[requirePaddingNewLinesAfterBlocks]: http://jscs.info/rule/requirePaddingNewLinesAfterBlocks\r\n"}}