{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/tslint/pulls/comments/52975142","id":52975142,"diff_hunk":"@@ -112,16 +105,138 @@ class TypedefWhitespaceWalker extends Lint.RuleWalker {\n \n     private getOption(option: string) {\n         const allOptions = this.getOptions();\n-        if (allOptions == null || allOptions.length === 0) {\n+        if (!this.hasOption(option)) {\n             return null;\n         }\n \n         const options = allOptions[0];\n         return options[option];\n     }\n-}\n \n-function positionBeforeColon(node: ts.Node): number {\n-    const colon = node.getChildren().filter((c) => c.kind === ts.SyntaxKind.ColonToken)[0];\n-    return colon == null ? -1 : colon.pos;\n+    private hasLeftOption(option: string): boolean {\n+        const optionConfig = this.getOption(option);\n+        return this.hasOption(option) &&\n+            (typeof optionConfig === \"string\" || optionConfig.left);\n+    }\n+\n+    private hasRightOption(option: string): boolean {\n+        const optionConfig = this.getOption(option);\n+        return this.hasOption(option) &&\n+            (typeof optionConfig === \"string\" || optionConfig.right);\n+    }\n+\n+    private getLeftOption(option: string): string {\n+        const optionConfig = this.getOption(option);\n+        if (!this.hasLeftOption(option)) {\n+            return null;\n+        }\n+\n+        return typeof optionConfig === \"string\" ? optionConfig : optionConfig.left;\n+    }\n+\n+    private getRightOption(option: string): string {\n+        const optionConfig = this.getOption(option);\n+        if (!this.hasRightOption(option)) {\n+            return null;\n+        }\n+\n+        return typeof optionConfig === \"string\" ? optionConfig : optionConfig.right;\n+    }\n+\n+    private checkLeft(option: string, node: ts.Node, scanner: ts.Scanner, colonPosition: number): void {\n+        let checkLeadingWhitespace: boolean = this.hasLeftOption(option);","path":"src/rules/typedefWhitespaceRule.ts","position":143,"original_position":143,"commit_id":"00a3676ee3b97feff3118b50bace4d04ea096575","original_commit_id":"00a3676ee3b97feff3118b50bace4d04ea096575","user":{"login":"JKillian","id":1400151,"avatar_url":"https://avatars.githubusercontent.com/u/1400151?v=3","gravatar_id":"","url":"https://api.github.com/users/JKillian","html_url":"https://github.com/JKillian","followers_url":"https://api.github.com/users/JKillian/followers","following_url":"https://api.github.com/users/JKillian/following{/other_user}","gists_url":"https://api.github.com/users/JKillian/gists{/gist_id}","starred_url":"https://api.github.com/users/JKillian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JKillian/subscriptions","organizations_url":"https://api.github.com/users/JKillian/orgs","repos_url":"https://api.github.com/users/JKillian/repos","events_url":"https://api.github.com/users/JKillian/events{/privacy}","received_events_url":"https://api.github.com/users/JKillian/received_events","type":"User","site_admin":false},"body":"Feel free to just inline this at line 149 since it's only used once there","created_at":"2016-02-16T07:19:17Z","updated_at":"2016-02-16T07:19:17Z","html_url":"https://github.com/palantir/tslint/pull/971#discussion_r52975142","pull_request_url":"https://api.github.com/repos/palantir/tslint/pulls/971","_links":{"self":{"href":"https://api.github.com/repos/palantir/tslint/pulls/comments/52975142"},"html":{"href":"https://github.com/palantir/tslint/pull/971#discussion_r52975142"},"pull_request":{"href":"https://api.github.com/repos/palantir/tslint/pulls/971"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/tslint/pulls/971","id":59281384,"html_url":"https://github.com/palantir/tslint/pull/971","diff_url":"https://github.com/palantir/tslint/pull/971.diff","patch_url":"https://github.com/palantir/tslint/pull/971.patch","issue_url":"https://api.github.com/repos/palantir/tslint/issues/971","number":971,"state":"open","locked":false,"title":"Extend options of typedef-whitespace rule to control whitespace on both sides of the typedef colon","user":{"login":"b0r3as","id":16087375,"avatar_url":"https://avatars.githubusercontent.com/u/16087375?v=3","gravatar_id":"","url":"https://api.github.com/users/b0r3as","html_url":"https://github.com/b0r3as","followers_url":"https://api.github.com/users/b0r3as/followers","following_url":"https://api.github.com/users/b0r3as/following{/other_user}","gists_url":"https://api.github.com/users/b0r3as/gists{/gist_id}","starred_url":"https://api.github.com/users/b0r3as/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/b0r3as/subscriptions","organizations_url":"https://api.github.com/users/b0r3as/orgs","repos_url":"https://api.github.com/users/b0r3as/repos","events_url":"https://api.github.com/users/b0r3as/events{/privacy}","received_events_url":"https://api.github.com/users/b0r3as/received_events","type":"User","site_admin":false},"body":"This feature was requested here: #888. \r\n\r\nThe rule configuration now could look like this (slashes meaning one of the three, of course): \r\n\r\n```json\r\n\"typedef-whitespace\": [\r\n  true,\r\n  {\r\n    \"call-signature\": \"nospace/space/spaces\",\r\n    \"index-signature\": {\r\n      \"left\": \"nospace/space/spaces\",\r\n      \"right\": \"nospace/space/spaces\"\r\n    },\r\n    \"parameter\": {\r\n      \"left\": \"nospace/space/spaces\",\r\n    },\r\n    \"property-declaration\": {\r\n      \"right\": \"nospace/space/spaces\"\r\n    },\r\n    \"variable-declaration\": {\r\n      \"left\": \"nospace\",\r\n      \"right\": \"space\"\r\n    }\r\n  }\r\n]\r\n```\r\n\r\nThe three possible values for an option are `\"nospace\"`, `\"space\"` and `\"spaces\"` meaning no space, exactly one and at least one space, respectively. If one of these values is placed directly on an option, it applies to both sides of the colon. This is a shorthand for setting `\"left\"` and `\"right\"` to the same value. \r\n\r\nYou can omit either `\"left\"` or `\"right\"`, which will skip the check for that side of the colon altogether.\r\n\r\n*This PR breaks compatibility*. If you had the options for this rule configured to `\"nospace/space\"` before, you would have to use\r\n\r\n```json\r\n{\r\n  \"left\": \"nospace/spaces\"\r\n}\r\n```\r\n\r\non each option now to replicate the exact same behaviour.\r\n","created_at":"2016-02-13T23:29:18Z","updated_at":"2016-02-16T07:19:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34d9b5210a9ed7b25089bf51c3f7a82f86ccaf8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/palantir/tslint/pulls/971/commits","review_comments_url":"https://api.github.com/repos/palantir/tslint/pulls/971/comments","review_comment_url":"https://api.github.com/repos/palantir/tslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/tslint/issues/971/comments","statuses_url":"https://api.github.com/repos/palantir/tslint/statuses/00a3676ee3b97feff3118b50bace4d04ea096575","head":{"label":"b0r3as:double-sided-typedef-whitespace","ref":"double-sided-typedef-whitespace","sha":"00a3676ee3b97feff3118b50bace4d04ea096575","user":{"login":"b0r3as","id":16087375,"avatar_url":"https://avatars.githubusercontent.com/u/16087375?v=3","gravatar_id":"","url":"https://api.github.com/users/b0r3as","html_url":"https://github.com/b0r3as","followers_url":"https://api.github.com/users/b0r3as/followers","following_url":"https://api.github.com/users/b0r3as/following{/other_user}","gists_url":"https://api.github.com/users/b0r3as/gists{/gist_id}","starred_url":"https://api.github.com/users/b0r3as/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/b0r3as/subscriptions","organizations_url":"https://api.github.com/users/b0r3as/orgs","repos_url":"https://api.github.com/users/b0r3as/repos","events_url":"https://api.github.com/users/b0r3as/events{/privacy}","received_events_url":"https://api.github.com/users/b0r3as/received_events","type":"User","site_admin":false},"repo":{"id":51619244,"name":"tslint","full_name":"b0r3as/tslint","owner":{"login":"b0r3as","id":16087375,"avatar_url":"https://avatars.githubusercontent.com/u/16087375?v=3","gravatar_id":"","url":"https://api.github.com/users/b0r3as","html_url":"https://github.com/b0r3as","followers_url":"https://api.github.com/users/b0r3as/followers","following_url":"https://api.github.com/users/b0r3as/following{/other_user}","gists_url":"https://api.github.com/users/b0r3as/gists{/gist_id}","starred_url":"https://api.github.com/users/b0r3as/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/b0r3as/subscriptions","organizations_url":"https://api.github.com/users/b0r3as/orgs","repos_url":"https://api.github.com/users/b0r3as/repos","events_url":"https://api.github.com/users/b0r3as/events{/privacy}","received_events_url":"https://api.github.com/users/b0r3as/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/b0r3as/tslint","description":"An extensible linter for the TypeScript language.","fork":true,"url":"https://api.github.com/repos/b0r3as/tslint","forks_url":"https://api.github.com/repos/b0r3as/tslint/forks","keys_url":"https://api.github.com/repos/b0r3as/tslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/b0r3as/tslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/b0r3as/tslint/teams","hooks_url":"https://api.github.com/repos/b0r3as/tslint/hooks","issue_events_url":"https://api.github.com/repos/b0r3as/tslint/issues/events{/number}","events_url":"https://api.github.com/repos/b0r3as/tslint/events","assignees_url":"https://api.github.com/repos/b0r3as/tslint/assignees{/user}","branches_url":"https://api.github.com/repos/b0r3as/tslint/branches{/branch}","tags_url":"https://api.github.com/repos/b0r3as/tslint/tags","blobs_url":"https://api.github.com/repos/b0r3as/tslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/b0r3as/tslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/b0r3as/tslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/b0r3as/tslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/b0r3as/tslint/statuses/{sha}","languages_url":"https://api.github.com/repos/b0r3as/tslint/languages","stargazers_url":"https://api.github.com/repos/b0r3as/tslint/stargazers","contributors_url":"https://api.github.com/repos/b0r3as/tslint/contributors","subscribers_url":"https://api.github.com/repos/b0r3as/tslint/subscribers","subscription_url":"https://api.github.com/repos/b0r3as/tslint/subscription","commits_url":"https://api.github.com/repos/b0r3as/tslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/b0r3as/tslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/b0r3as/tslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/b0r3as/tslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/b0r3as/tslint/contents/{+path}","compare_url":"https://api.github.com/repos/b0r3as/tslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/b0r3as/tslint/merges","archive_url":"https://api.github.com/repos/b0r3as/tslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/b0r3as/tslint/downloads","issues_url":"https://api.github.com/repos/b0r3as/tslint/issues{/number}","pulls_url":"https://api.github.com/repos/b0r3as/tslint/pulls{/number}","milestones_url":"https://api.github.com/repos/b0r3as/tslint/milestones{/number}","notifications_url":"https://api.github.com/repos/b0r3as/tslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/b0r3as/tslint/labels{/name}","releases_url":"https://api.github.com/repos/b0r3as/tslint/releases{/id}","deployments_url":"https://api.github.com/repos/b0r3as/tslint/deployments","created_at":"2016-02-12T21:58:45Z","updated_at":"2016-02-12T21:58:46Z","pushed_at":"2016-02-13T22:57:40Z","git_url":"git://github.com/b0r3as/tslint.git","ssh_url":"git@github.com:b0r3as/tslint.git","clone_url":"https://github.com/b0r3as/tslint.git","svn_url":"https://github.com/b0r3as/tslint","homepage":"http://palantir.github.io/tslint/","size":9850,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"palantir:master","ref":"master","sha":"dc5e07fab29e578e1e4cc06b2b27db60bb650e6e","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":11672345,"name":"tslint","full_name":"palantir/tslint","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/tslint","description":"An extensible linter for the TypeScript language.","fork":false,"url":"https://api.github.com/repos/palantir/tslint","forks_url":"https://api.github.com/repos/palantir/tslint/forks","keys_url":"https://api.github.com/repos/palantir/tslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/tslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/tslint/teams","hooks_url":"https://api.github.com/repos/palantir/tslint/hooks","issue_events_url":"https://api.github.com/repos/palantir/tslint/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/tslint/events","assignees_url":"https://api.github.com/repos/palantir/tslint/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/tslint/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/tslint/tags","blobs_url":"https://api.github.com/repos/palantir/tslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/tslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/tslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/tslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/tslint/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/tslint/languages","stargazers_url":"https://api.github.com/repos/palantir/tslint/stargazers","contributors_url":"https://api.github.com/repos/palantir/tslint/contributors","subscribers_url":"https://api.github.com/repos/palantir/tslint/subscribers","subscription_url":"https://api.github.com/repos/palantir/tslint/subscription","commits_url":"https://api.github.com/repos/palantir/tslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/tslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/tslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/tslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/tslint/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/tslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/tslint/merges","archive_url":"https://api.github.com/repos/palantir/tslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/tslint/downloads","issues_url":"https://api.github.com/repos/palantir/tslint/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/tslint/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/tslint/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/tslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/tslint/labels{/name}","releases_url":"https://api.github.com/repos/palantir/tslint/releases{/id}","deployments_url":"https://api.github.com/repos/palantir/tslint/deployments","created_at":"2013-07-25T22:19:18Z","updated_at":"2016-02-16T00:14:43Z","pushed_at":"2016-02-13T23:29:19Z","git_url":"git://github.com/palantir/tslint.git","ssh_url":"git@github.com:palantir/tslint.git","clone_url":"https://github.com/palantir/tslint.git","svn_url":"https://github.com/palantir/tslint","homepage":"http://palantir.github.io/tslint/","size":10531,"stargazers_count":560,"watchers_count":560,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":144,"mirror_url":null,"open_issues_count":172,"forks":144,"open_issues":172,"watchers":560,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/tslint/pulls/971"},"html":{"href":"https://github.com/palantir/tslint/pull/971"},"issue":{"href":"https://api.github.com/repos/palantir/tslint/issues/971"},"comments":{"href":"https://api.github.com/repos/palantir/tslint/issues/971/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/tslint/pulls/971/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/tslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/tslint/pulls/971/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/tslint/statuses/00a3676ee3b97feff3118b50bace4d04ea096575"}}}}