{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/5696","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/5696/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/5696/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/5696/events","html_url":"https://github.com/eslint/eslint/pull/5696","id":143827872,"number":5696,"title":"Update: Include 'typeof' in rule 'no-constant-condition' (fixes #5228)","user":{"login":"pvamshi","id":1425006,"avatar_url":"https://avatars.githubusercontent.com/u/1425006?v=3","gravatar_id":"","url":"https://api.github.com/users/pvamshi","html_url":"https://github.com/pvamshi","followers_url":"https://api.github.com/users/pvamshi/followers","following_url":"https://api.github.com/users/pvamshi/following{/other_user}","gists_url":"https://api.github.com/users/pvamshi/gists{/gist_id}","starred_url":"https://api.github.com/users/pvamshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvamshi/subscriptions","organizations_url":"https://api.github.com/users/pvamshi/orgs","repos_url":"https://api.github.com/users/pvamshi/repos","events_url":"https://api.github.com/users/pvamshi/events{/privacy}","received_events_url":"https://api.github.com/users/pvamshi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/cla%20found","name":"cla found","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-03-27T16:56:35Z","updated_at":"2016-03-28T03:35:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/eslint/eslint/pulls/5696","html_url":"https://github.com/eslint/eslint/pull/5696","diff_url":"https://github.com/eslint/eslint/pull/5696.diff","patch_url":"https://github.com/eslint/eslint/pull/5696.patch"},"body":"Adding new condition to the rule 'no-constant-condition' as discussed in #5228 . More test cases can be added as part of #5693 ."},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/202218342","html_url":"https://github.com/eslint/eslint/pull/5696#issuecomment-202218342","issue_url":"https://api.github.com/repos/eslint/eslint/issues/5696","id":202218342,"user":{"login":"platinumazure","id":284282,"avatar_url":"https://avatars.githubusercontent.com/u/284282?v=3","gravatar_id":"","url":"https://api.github.com/users/platinumazure","html_url":"https://github.com/platinumazure","followers_url":"https://api.github.com/users/platinumazure/followers","following_url":"https://api.github.com/users/platinumazure/following{/other_user}","gists_url":"https://api.github.com/users/platinumazure/gists{/gist_id}","starred_url":"https://api.github.com/users/platinumazure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/platinumazure/subscriptions","organizations_url":"https://api.github.com/users/platinumazure/orgs","repos_url":"https://api.github.com/users/platinumazure/repos","events_url":"https://api.github.com/users/platinumazure/events{/privacy}","received_events_url":"https://api.github.com/users/platinumazure/received_events","type":"User","site_admin":false},"created_at":"2016-03-28T03:35:43Z","updated_at":"2016-03-28T03:35:43Z","body":"@pvamshi Of course, sorry for omitting it earlier.\r\n\r\nExample constant conditions:\r\n* `typeof \"str\" === \"string\"`\r\n* `typeof 1 === \"string\"`\r\n* `typeof [arr] === \"object\"`\r\n* `typeof { key: val } === \"object\"`\r\n* `typeof \"a literal\" === \"invalid type\"`\r\n\r\nAll of those are comparing against known types that can't be altered via changes in variable data. (This is true of the ArrayExpression and ObjectExpression, and this is true even if the other side of the relational operator is an invalid typeof value-- the condition will just be false in that case.)\r\n\r\nExample non-constant conditions:\r\n* `typeof variable === \"string\"`\r\n\r\nMore advanced constant condition:\r\n* `const value = 5; typeof value === \"number\"` (The actual value doesn't matter-- just the fact that the variable is `const` matters.)"}}