{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/tslint/pulls/comments/61608195","id":61608195,"diff_hunk":"@@ -240,7 +240,9 @@ A sample configuration file with all options is available [here](https://github.\n * `no-eval` disallows `eval` function invocations.\n * `no-inferrable-types` disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.\n * `no-internal-module` disallows internal `module` (use `namespace` instead).\n-* `no-invalid-this` disallows using the `this` keyword outside of classes.\n+* `no-invalid-this` disallows using the `this` keyword in scopes where they are often misinterpreted\n+    * `outside-of-class` disallows using the `this` keyword outside of classes.","path":"README.md","position":6,"original_position":6,"commit_id":"a07c09753e7e040bec48a0870d38fecdfe3c3c81","original_commit_id":"a07c09753e7e040bec48a0870d38fecdfe3c3c81","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":"Can we keep this behavior on by default? For backwards-compat reasons, we don't want to have to make users add a new option to their rule to get the same behavior as before","created_at":"2016-04-29T16:53:26Z","updated_at":"2016-04-29T16:53:26Z","html_url":"https://github.com/palantir/tslint/pull/1179#discussion_r61608195","pull_request_url":"https://api.github.com/repos/palantir/tslint/pulls/1179","_links":{"self":{"href":"https://api.github.com/repos/palantir/tslint/pulls/comments/61608195"},"html":{"href":"https://github.com/palantir/tslint/pull/1179#discussion_r61608195"},"pull_request":{"href":"https://api.github.com/repos/palantir/tslint/pulls/1179"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/tslint/pulls/1179","id":68297595,"html_url":"https://github.com/palantir/tslint/pull/1179","diff_url":"https://github.com/palantir/tslint/pull/1179.diff","patch_url":"https://github.com/palantir/tslint/pull/1179.patch","issue_url":"https://api.github.com/repos/palantir/tslint/issues/1179","number":1179,"state":"open","locked":false,"title":"Extend no-invalid-this rule to disallow `this` in functions in methods","user":{"login":"inthemill","id":488655,"avatar_url":"https://avatars.githubusercontent.com/u/488655?v=3","gravatar_id":"","url":"https://api.github.com/users/inthemill","html_url":"https://github.com/inthemill","followers_url":"https://api.github.com/users/inthemill/followers","following_url":"https://api.github.com/users/inthemill/following{/other_user}","gists_url":"https://api.github.com/users/inthemill/gists{/gist_id}","starred_url":"https://api.github.com/users/inthemill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inthemill/subscriptions","organizations_url":"https://api.github.com/users/inthemill/orgs","repos_url":"https://api.github.com/users/inthemill/repos","events_url":"https://api.github.com/users/inthemill/events{/privacy}","received_events_url":"https://api.github.com/users/inthemill/received_events","type":"User","site_admin":false},"body":"This PR extends the [no-invalid-this] with the option \"in-function-in-method\".\r\nIf it is enabled it complains about the usage of the `this` keyword inside of function expression within a method.\r\n`this` in such function expressions is usually meant to refer the this outside of the functions scope.\r\n This rule will not complain about this in arrow functions.\r\n\r\nIn our project, it happened often when migrating JS to TS. With an angular service written as\r\n```javascript\r\nangular.module('a',[]).factory('Service', function(Helper, Enhancer){\r\nreturn {\r\n    getAllMapped: function(){\r\n         return Helper.getAll()\r\n             .map(function(item){\r\n                  return Enhancer.enhance(item);\r\n             })\r\n    }\r\n}\r\n}); \r\n```\r\nWe often end up with\r\n```javascript\r\nclass ServiceClass {\r\n    constructor(private Helper, private Enhancer){\r\n    }\r\n\r\n    public getAllMapped() {\r\n         return this.Helper.getAll()\r\n             .map(function(item){\r\n                  return this.Enhancer.enhance(item);\r\n             })\r\n    }\r\n}\r\nangular.module('a',[]).service('Service', ServiceClass);\r\n```\r\nwhich will not work as ```this.Enhancer``` is not defined.","created_at":"2016-04-28T21:59:27Z","updated_at":"2016-04-29T16:53:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49bf0e47a1fdf7547d6bbdc8ec5e7f8a74b81857","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/palantir/tslint/pulls/1179/commits","review_comments_url":"https://api.github.com/repos/palantir/tslint/pulls/1179/comments","review_comment_url":"https://api.github.com/repos/palantir/tslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/tslint/issues/1179/comments","statuses_url":"https://api.github.com/repos/palantir/tslint/statuses/a07c09753e7e040bec48a0870d38fecdfe3c3c81","head":{"label":"inthemill:master","ref":"master","sha":"a07c09753e7e040bec48a0870d38fecdfe3c3c81","user":{"login":"inthemill","id":488655,"avatar_url":"https://avatars.githubusercontent.com/u/488655?v=3","gravatar_id":"","url":"https://api.github.com/users/inthemill","html_url":"https://github.com/inthemill","followers_url":"https://api.github.com/users/inthemill/followers","following_url":"https://api.github.com/users/inthemill/following{/other_user}","gists_url":"https://api.github.com/users/inthemill/gists{/gist_id}","starred_url":"https://api.github.com/users/inthemill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inthemill/subscriptions","organizations_url":"https://api.github.com/users/inthemill/orgs","repos_url":"https://api.github.com/users/inthemill/repos","events_url":"https://api.github.com/users/inthemill/events{/privacy}","received_events_url":"https://api.github.com/users/inthemill/received_events","type":"User","site_admin":false},"repo":{"id":57334543,"name":"tslint","full_name":"inthemill/tslint","owner":{"login":"inthemill","id":488655,"avatar_url":"https://avatars.githubusercontent.com/u/488655?v=3","gravatar_id":"","url":"https://api.github.com/users/inthemill","html_url":"https://github.com/inthemill","followers_url":"https://api.github.com/users/inthemill/followers","following_url":"https://api.github.com/users/inthemill/following{/other_user}","gists_url":"https://api.github.com/users/inthemill/gists{/gist_id}","starred_url":"https://api.github.com/users/inthemill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inthemill/subscriptions","organizations_url":"https://api.github.com/users/inthemill/orgs","repos_url":"https://api.github.com/users/inthemill/repos","events_url":"https://api.github.com/users/inthemill/events{/privacy}","received_events_url":"https://api.github.com/users/inthemill/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/inthemill/tslint","description":"An extensible linter for the TypeScript language.","fork":true,"url":"https://api.github.com/repos/inthemill/tslint","forks_url":"https://api.github.com/repos/inthemill/tslint/forks","keys_url":"https://api.github.com/repos/inthemill/tslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inthemill/tslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inthemill/tslint/teams","hooks_url":"https://api.github.com/repos/inthemill/tslint/hooks","issue_events_url":"https://api.github.com/repos/inthemill/tslint/issues/events{/number}","events_url":"https://api.github.com/repos/inthemill/tslint/events","assignees_url":"https://api.github.com/repos/inthemill/tslint/assignees{/user}","branches_url":"https://api.github.com/repos/inthemill/tslint/branches{/branch}","tags_url":"https://api.github.com/repos/inthemill/tslint/tags","blobs_url":"https://api.github.com/repos/inthemill/tslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inthemill/tslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inthemill/tslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/inthemill/tslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inthemill/tslint/statuses/{sha}","languages_url":"https://api.github.com/repos/inthemill/tslint/languages","stargazers_url":"https://api.github.com/repos/inthemill/tslint/stargazers","contributors_url":"https://api.github.com/repos/inthemill/tslint/contributors","subscribers_url":"https://api.github.com/repos/inthemill/tslint/subscribers","subscription_url":"https://api.github.com/repos/inthemill/tslint/subscription","commits_url":"https://api.github.com/repos/inthemill/tslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/inthemill/tslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/inthemill/tslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/inthemill/tslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/inthemill/tslint/contents/{+path}","compare_url":"https://api.github.com/repos/inthemill/tslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inthemill/tslint/merges","archive_url":"https://api.github.com/repos/inthemill/tslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inthemill/tslint/downloads","issues_url":"https://api.github.com/repos/inthemill/tslint/issues{/number}","pulls_url":"https://api.github.com/repos/inthemill/tslint/pulls{/number}","milestones_url":"https://api.github.com/repos/inthemill/tslint/milestones{/number}","notifications_url":"https://api.github.com/repos/inthemill/tslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inthemill/tslint/labels{/name}","releases_url":"https://api.github.com/repos/inthemill/tslint/releases{/id}","deployments_url":"https://api.github.com/repos/inthemill/tslint/deployments","created_at":"2016-04-28T21:21:58Z","updated_at":"2016-04-28T21:22:00Z","pushed_at":"2016-04-28T21:43:21Z","git_url":"git://github.com/inthemill/tslint.git","ssh_url":"git@github.com:inthemill/tslint.git","clone_url":"https://github.com/inthemill/tslint.git","svn_url":"https://github.com/inthemill/tslint","homepage":"http://palantir.github.io/tslint/","size":9693,"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":"62a57af395040b142c9a3616b0f892a027283382","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-04-29T16:21:20Z","pushed_at":"2016-04-29T06:44:25Z","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":10719,"stargazers_count":700,"watchers_count":700,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":187,"mirror_url":null,"open_issues_count":216,"forks":187,"open_issues":216,"watchers":700,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/tslint/pulls/1179"},"html":{"href":"https://github.com/palantir/tslint/pull/1179"},"issue":{"href":"https://api.github.com/repos/palantir/tslint/issues/1179"},"comments":{"href":"https://api.github.com/repos/palantir/tslint/issues/1179/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/tslint/pulls/1179/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/tslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/tslint/pulls/1179/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/tslint/statuses/a07c09753e7e040bec48a0870d38fecdfe3c3c81"}}}}