{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib/issues/171","repository_url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib","labels_url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib/issues/171/comments","events_url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib/issues/171/events","html_url":"https://github.com/Microsoft/tslint-microsoft-contrib/issues/171","id":164137193,"number":171,"title":"new rule: no-unsupported-browser-code","user":{"login":"AdamTReineke","id":518655,"avatar_url":"https://avatars.githubusercontent.com/u/518655?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamTReineke","html_url":"https://github.com/AdamTReineke","followers_url":"https://api.github.com/users/AdamTReineke/followers","following_url":"https://api.github.com/users/AdamTReineke/following{/other_user}","gists_url":"https://api.github.com/users/AdamTReineke/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamTReineke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamTReineke/subscriptions","organizations_url":"https://api.github.com/users/AdamTReineke/orgs","repos_url":"https://api.github.com/users/AdamTReineke/repos","events_url":"https://api.github.com/users/AdamTReineke/events{/privacy}","received_events_url":"https://api.github.com/users/AdamTReineke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-06T18:00:34Z","updated_at":"2016-07-07T06:14:45Z","closed_at":null,"body":"It's easy to accumulate lots of browser specific code when adding workarounds for browser bugs. This new rule would use the tslint.json to specify which browser versions you care about supporting, then specifically formatted comments to annotate all browser hacks. As you drop support for older browsers and change the tslint.json configuration, tslint would flag the comments so you can remove the code.\r\n\r\nSome examples from our code base, annotated with new \"Browser Specific\" comments:\r\n\r\n````typescript\r\n// Called when we get a pointer down event for IE11\r\n// Browser Specific: IE 11\r\ndocument.body.addEventListener(\"pointerdown\", function (event: MSPointerEvent) {\r\n    if (event.pointerType !== \"mouse\") { ... }\r\n}, false);\r\n\r\n// Called when we get a pointer down event for IE10\r\n// Browser Specific: IE 10\r\ndocument.body.addEventListener(\"MSPointerDown\", function (event: MSPointerEvent) {\r\n    if (event.pointerType === event.MSPOINTER_TYPE_PEN) { ... }\r\n    else if (event.pointerType === event.MSPOINTER_TYPE_TOUCH) { ... }\r\n}, false);\r\n````\r\n\r\n````typescript\r\n// Work around bug where this doesn't render on iOS by forcing the hardware to do it\r\n// Browser Specific: Mobile Safari\r\nif (Utilities.browser.isSafari && !Utilities.browser.isChrome && Utilities.browser.isMobile) {\r\n\tstyle[\"transform\"] = \"translate3d(0,0,0)\";\r\n}\r\n````\r\n\r\nIf we dropped support for IE 10, the event listener would be flagged and we could remove that code from our code base.\r\n\r\nSome additional thinking is needed to come up with a decent grammar for designating the browser versions. `@browserspecific <string>` (for JSdoc usages) or `Browser Specific: <string>` seem like good tags around the string itself.\r\n\r\nA grammar something like `[Mobile] (Safari|Chrome|Firefox|FF|Internet Explorer|IE|Edge) [[>|<]<number>]` would lead to comments like `Mobile Safari < 8` or `Chrome > 45` or `IE`, which seems ok."},"comment":{"url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib/issues/comments/230988155","html_url":"https://github.com/Microsoft/tslint-microsoft-contrib/issues/171#issuecomment-230988155","issue_url":"https://api.github.com/repos/Microsoft/tslint-microsoft-contrib/issues/171","id":230988155,"user":{"login":"HamletDRC","id":186401,"avatar_url":"https://avatars.githubusercontent.com/u/186401?v=3","gravatar_id":"","url":"https://api.github.com/users/HamletDRC","html_url":"https://github.com/HamletDRC","followers_url":"https://api.github.com/users/HamletDRC/followers","following_url":"https://api.github.com/users/HamletDRC/following{/other_user}","gists_url":"https://api.github.com/users/HamletDRC/gists{/gist_id}","starred_url":"https://api.github.com/users/HamletDRC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HamletDRC/subscriptions","organizations_url":"https://api.github.com/users/HamletDRC/orgs","repos_url":"https://api.github.com/users/HamletDRC/repos","events_url":"https://api.github.com/users/HamletDRC/events{/privacy}","received_events_url":"https://api.github.com/users/HamletDRC/received_events","type":"User","site_admin":false},"created_at":"2016-07-07T06:14:45Z","updated_at":"2016-07-07T06:14:45Z","body":"Great. idea. It seems pretty easy to implement. \r\n\r\nto configure the rule you could list your supported browers and have something like: \r\n\r\n    no-unsupported-browser-code: [ true, [\r\n        \"IE 10\",\r\n        \"IE 11\",\r\n        \"Chrome [4-9][0-9]\",   // regex for 40 to 99\r\n    ]]\r\n\r\n"}}
{"actor":{"display_login":"HamletDRC"}}