{"action":"closed","number":2857,"pull_request":{"url":"https://api.github.com/repos/eslint/eslint/pulls/2857","id":38698983,"html_url":"https://github.com/eslint/eslint/pull/2857","diff_url":"https://github.com/eslint/eslint/pull/2857.diff","patch_url":"https://github.com/eslint/eslint/pull/2857.patch","issue_url":"https://api.github.com/repos/eslint/eslint/issues/2857","number":2857,"state":"closed","locked":false,"title":"New: `no-invalid-this` rule (fixes #2815)","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},"body":"I wrote, but it became larger than the first code...\r\nI think what this rule does might not be simple, but is still not complex: just checking the function node and its parent node, almost.\r\n\r\nThe main reason that becomes larger than the first is processes for options.\r\n\r\nNow, this rule two options.\r\n\r\n1. `surelyUndefinedOnly` - If this is `true`, this rule warns only cases that `this` is `undefined` absolutely. In order to do so, I need to check whether or not this is under strict mode.\r\n2. `allowInCallback` - If this is given an array of function names, `this` turns valid in callbacks of the functions.\r\n\r\nAs a test, I validated the source code of ESLint by this rule, there are some warnings in callbacks of `forEach` and `sinon.test`. This rule warned nothing (excepts in callbacks), so this implementation works as I expected. Actually both `this` in callbacks is valid, but we can turn off the warnings by `allowInCallback` option easily.\r\n\r\n  ```\r\n  Validating JavaScript files\r\n\r\n  lib/rule-context.js\r\n    83:8  error  Unexpected `this`  no-invalid-this\r\n\r\n  lib/rules/no-irregular-whitespace.js\r\n    129:37  error  Unexpected `this`  no-invalid-this\r\n\r\n  ✖ 2 problems (2 errors, 0 warnings)\r\n\r\n  Validating JavaScript test files\r\n\r\n  tests/lib/cli-engine.js\r\n    834:35  error  Unexpected `this`  no-invalid-this\r\n\r\n  tests/lib/traverse.js\r\n    133:23  error  Unexpected `this`  no-invalid-this\r\n    135:8   error  Unexpected `this`  no-invalid-this\r\n\r\n  ✖ 3 problems (3 errors, 0 warnings)\r\n  ```\r\n\r\n  ","created_at":"2015-06-26T23:50:41Z","updated_at":"2015-07-20T15:34:58Z","closed_at":"2015-07-20T15:34:58Z","merged_at":"2015-07-20T15:34:58Z","merge_commit_sha":"05e2bb6be98f8a7d6be6078c312cf981740756ac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eslint/eslint/pulls/2857/commits","review_comments_url":"https://api.github.com/repos/eslint/eslint/pulls/2857/comments","review_comment_url":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/2857/comments","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/7996fc190235018dd4f2d12a8bb05223fccac29b","head":{"label":"mysticatea:no-invalid-this/new","ref":"no-invalid-this/new","sha":"7996fc190235018dd4f2d12a8bb05223fccac29b","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},"repo":{"id":34937068,"name":"eslint","full_name":"mysticatea/eslint","owner":{"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},"private":false,"html_url":"https://github.com/mysticatea/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":true,"url":"https://api.github.com/repos/mysticatea/eslint","forks_url":"https://api.github.com/repos/mysticatea/eslint/forks","keys_url":"https://api.github.com/repos/mysticatea/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mysticatea/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mysticatea/eslint/teams","hooks_url":"https://api.github.com/repos/mysticatea/eslint/hooks","issue_events_url":"https://api.github.com/repos/mysticatea/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/mysticatea/eslint/events","assignees_url":"https://api.github.com/repos/mysticatea/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/mysticatea/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/mysticatea/eslint/tags","blobs_url":"https://api.github.com/repos/mysticatea/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mysticatea/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mysticatea/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/mysticatea/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mysticatea/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/mysticatea/eslint/languages","stargazers_url":"https://api.github.com/repos/mysticatea/eslint/stargazers","contributors_url":"https://api.github.com/repos/mysticatea/eslint/contributors","subscribers_url":"https://api.github.com/repos/mysticatea/eslint/subscribers","subscription_url":"https://api.github.com/repos/mysticatea/eslint/subscription","commits_url":"https://api.github.com/repos/mysticatea/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/mysticatea/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/mysticatea/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/mysticatea/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/mysticatea/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/mysticatea/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mysticatea/eslint/merges","archive_url":"https://api.github.com/repos/mysticatea/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mysticatea/eslint/downloads","issues_url":"https://api.github.com/repos/mysticatea/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/mysticatea/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/mysticatea/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/mysticatea/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mysticatea/eslint/labels{/name}","releases_url":"https://api.github.com/repos/mysticatea/eslint/releases{/id}","created_at":"2015-05-02T05:43:17Z","updated_at":"2015-05-02T05:43:21Z","pushed_at":"2015-07-20T04:32:07Z","git_url":"git://github.com/mysticatea/eslint.git","ssh_url":"git@github.com:mysticatea/eslint.git","clone_url":"https://github.com/mysticatea/eslint.git","svn_url":"https://github.com/mysticatea/eslint","homepage":"http://eslint.org","size":6453,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"eslint:master","ref":"master","sha":"4ea9a53044e598bb4f2c3e6b37625d735b4826af","user":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"repo":{"id":11061773,"name":"eslint","full_name":"eslint/eslint","owner":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eslint/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":false,"url":"https://api.github.com/repos/eslint/eslint","forks_url":"https://api.github.com/repos/eslint/eslint/forks","keys_url":"https://api.github.com/repos/eslint/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eslint/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eslint/eslint/teams","hooks_url":"https://api.github.com/repos/eslint/eslint/hooks","issue_events_url":"https://api.github.com/repos/eslint/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/eslint/eslint/events","assignees_url":"https://api.github.com/repos/eslint/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/eslint/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/eslint/eslint/tags","blobs_url":"https://api.github.com/repos/eslint/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eslint/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eslint/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/eslint/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/eslint/eslint/languages","stargazers_url":"https://api.github.com/repos/eslint/eslint/stargazers","contributors_url":"https://api.github.com/repos/eslint/eslint/contributors","subscribers_url":"https://api.github.com/repos/eslint/eslint/subscribers","subscription_url":"https://api.github.com/repos/eslint/eslint/subscription","commits_url":"https://api.github.com/repos/eslint/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/eslint/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/eslint/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/eslint/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/eslint/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/eslint/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eslint/eslint/merges","archive_url":"https://api.github.com/repos/eslint/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eslint/eslint/downloads","issues_url":"https://api.github.com/repos/eslint/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/eslint/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/eslint/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/eslint/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eslint/eslint/labels{/name}","releases_url":"https://api.github.com/repos/eslint/eslint/releases{/id}","created_at":"2013-06-29T23:59:48Z","updated_at":"2015-07-20T13:42:17Z","pushed_at":"2015-07-20T15:34:58Z","git_url":"git://github.com/eslint/eslint.git","ssh_url":"git@github.com:eslint/eslint.git","clone_url":"https://github.com/eslint/eslint.git","svn_url":"https://github.com/eslint/eslint","homepage":"http://eslint.org","size":18258,"stargazers_count":2532,"watchers_count":2532,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":471,"mirror_url":null,"open_issues_count":152,"forks":471,"open_issues":152,"watchers":2532,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/2857"},"html":{"href":"https://github.com/eslint/eslint/pull/2857"},"issue":{"href":"https://api.github.com/repos/eslint/eslint/issues/2857"},"comments":{"href":"https://api.github.com/repos/eslint/eslint/issues/2857/comments"},"review_comments":{"href":"https://api.github.com/repos/eslint/eslint/pulls/2857/comments"},"review_comment":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eslint/eslint/pulls/2857/commits"},"statuses":{"href":"https://api.github.com/repos/eslint/eslint/statuses/7996fc190235018dd4f2d12a8bb05223fccac29b"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"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},"comments":23,"review_comments":4,"commits":1,"additions":1076,"deletions":3,"changed_files":9}}