{"action":"created","issue":{"url":"https://api.github.com/repos/jshint/jshint/issues/2528","labels_url":"https://api.github.com/repos/jshint/jshint/issues/2528/labels{/name}","comments_url":"https://api.github.com/repos/jshint/jshint/issues/2528/comments","events_url":"https://api.github.com/repos/jshint/jshint/issues/2528/events","html_url":"https://github.com/jshint/jshint/issues/2528","id":93107039,"number":2528,"title":"Ternary line breaking","user":{"login":"prettydiff","id":524902,"avatar_url":"https://avatars.githubusercontent.com/u/524902?v=3","gravatar_id":"","url":"https://api.github.com/users/prettydiff","html_url":"https://github.com/prettydiff","followers_url":"https://api.github.com/users/prettydiff/followers","following_url":"https://api.github.com/users/prettydiff/following{/other_user}","gists_url":"https://api.github.com/users/prettydiff/gists{/gist_id}","starred_url":"https://api.github.com/users/prettydiff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prettydiff/subscriptions","organizations_url":"https://api.github.com/users/prettydiff/orgs","repos_url":"https://api.github.com/users/prettydiff/repos","events_url":"https://api.github.com/users/prettydiff/events{/privacy}","received_events_url":"https://api.github.com/users/prettydiff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-05T12:17:20Z","updated_at":"2015-07-05T18:48:28Z","closed_at":null,"body":"    var a = (tern)\r\n        ? b\r\n        : c;\r\n\r\nThis code produces the warning: `Bad line breaking before '?'.`\r\n\r\nThe jshint flow control is:\r\n\r\nFirst catch the \"?\" token and then pass it to the expression function\r\n\r\n      infix(\"?\", function(left, that) {\r\n        increaseComplexityCount();\r\n        that.left = left;\r\n        that.right = expression(10);\r\n        advance(\":\");\r\n        that[\"else\"] = expression(10);\r\n        return that;\r\n      }, 30);\r\n\r\nFunction expression contains this logic near it's start\r\n\r\n        var isDangerous =\r\n          state.option.asi &&\r\n          state.tokens.prev.line !== startLine(state.tokens.curr) &&\r\n          _.contains([\"]\", \")\"], state.tokens.prev.id) &&\r\n          _.contains([\"[\", \"(\"], state.tokens.curr.id);\r\n    \r\n        if (isDangerous)\r\n          warning(\"W014\", state.tokens.curr, state.tokens.curr.id);\r\n\r\nIt appears the JSHint code is incorrectly catching the line break between the \")\" and the \"?\" in its ASI logic.  ASI must not apply in this case.  Breaking a ternary onto multiple lines makes the code easier to read.  Example:\r\n\r\n    var a = (tern1 > 0)\r\n            ? b\r\n            : (tern2 > x)\r\n                ? c\r\n                : d,\r\n        e = 1;"},"comment":{"url":"https://api.github.com/repos/jshint/jshint/issues/comments/118649856","html_url":"https://github.com/jshint/jshint/issues/2528#issuecomment-118649856","issue_url":"https://api.github.com/repos/jshint/jshint/issues/2528","id":118649856,"user":{"login":"kaizer200","id":11957148,"avatar_url":"https://avatars.githubusercontent.com/u/11957148?v=3","gravatar_id":"","url":"https://api.github.com/users/kaizer200","html_url":"https://github.com/kaizer200","followers_url":"https://api.github.com/users/kaizer200/followers","following_url":"https://api.github.com/users/kaizer200/following{/other_user}","gists_url":"https://api.github.com/users/kaizer200/gists{/gist_id}","starred_url":"https://api.github.com/users/kaizer200/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaizer200/subscriptions","organizations_url":"https://api.github.com/users/kaizer200/orgs","repos_url":"https://api.github.com/users/kaizer200/repos","events_url":"https://api.github.com/users/kaizer200/events{/privacy}","received_events_url":"https://api.github.com/users/kaizer200/received_events","type":"User","site_admin":false},"created_at":"2015-07-05T18:48:28Z","updated_at":"2015-07-05T18:48:28Z","body":"why are you still using JSHint, and not only JSLint which is much better? "}}