{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/4288","labels_url":"https://api.github.com/repos/eslint/eslint/issues/4288/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/4288/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/4288/events","html_url":"https://github.com/eslint/eslint/issues/4288","id":114027624,"number":4288,"title":"[new-cap] false positive when constructor is returned by chained function call","user":{"login":"jrencz","id":948356,"avatar_url":"https://avatars.githubusercontent.com/u/948356?v=3","gravatar_id":"","url":"https://api.github.com/users/jrencz","html_url":"https://github.com/jrencz","followers_url":"https://api.github.com/users/jrencz/followers","following_url":"https://api.github.com/users/jrencz/following{/other_user}","gists_url":"https://api.github.com/users/jrencz/gists{/gist_id}","starred_url":"https://api.github.com/users/jrencz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrencz/subscriptions","organizations_url":"https://api.github.com/users/jrencz/orgs","repos_url":"https://api.github.com/users/jrencz/repos","events_url":"https://api.github.com/users/jrencz/events{/privacy}","received_events_url":"https://api.github.com/users/jrencz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/triage","name":"triage","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-29T11:10:01Z","updated_at":"2015-10-29T11:10:09Z","closed_at":null,"body":"Please consider the following snippet:\r\n\r\n```es6\r\nconst foo = {bar: function BazService () {}};\r\n\r\nconst serviceCache = new Map();\r\nserviceCache.set(\"baz\", foo.bar.BazService);\r\n\r\nconst bazInstance1 = new serviceCache.get(\"baz\").BazService();\r\nconst bazInstance2 = new foo.bar.BazService();\r\n\r\nbazInstance1(\"quux\");\r\nbazInstance2(\"quux\");\r\n```\r\n\r\nWhen pasted into [demo](http://eslint.org/demo/) with default settings + `es6` and `new-cap` it produces 2 errors for line 6 which uses Map#get to access the constructor previously stored in `serviceCache`:\r\n```\r\n6:39 - A constructor name should not start with a lowercase letter. (new-cap)\r\n6:50 - A function with a name starting with an uppercase letter should only be used as a constructor. (new-cap)\r\n```\r\n\r\nNote that in line 7, where the same constructor is accessed, but without function call in chain there's no error reported.\r\n\r\nExpected behaviour for `new-cap` in this case is not to report any error.\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27797316-new-cap-false-positive-when-constructor-is-returned-by-chained-function-call?utm_campaign=plugin&utm_content=tracker%2F282608&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282608&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/152148581","html_url":"https://github.com/eslint/eslint/issues/4288#issuecomment-152148581","issue_url":"https://api.github.com/repos/eslint/eslint/issues/4288","id":152148581,"user":{"login":"eslintbot","id":13383618,"avatar_url":"https://avatars.githubusercontent.com/u/13383618?v=3","gravatar_id":"","url":"https://api.github.com/users/eslintbot","html_url":"https://github.com/eslintbot","followers_url":"https://api.github.com/users/eslintbot/followers","following_url":"https://api.github.com/users/eslintbot/following{/other_user}","gists_url":"https://api.github.com/users/eslintbot/gists{/gist_id}","starred_url":"https://api.github.com/users/eslintbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslintbot/subscriptions","organizations_url":"https://api.github.com/users/eslintbot/orgs","repos_url":"https://api.github.com/users/eslintbot/repos","events_url":"https://api.github.com/users/eslintbot/events{/privacy}","received_events_url":"https://api.github.com/users/eslintbot/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T11:10:09Z","updated_at":"2015-10-29T11:10:09Z","body":"Thanks for the issue! If you're reporting a bug, please be sure to include:\n\n1. The version of ESLint you are using (run `eslint -v`)\n2. What you did (the source code and ESLint configuration)\n3. The actual ESLint output complete with numbers\n4. What you expected to happen instead\n\nRequesting a new rule? Please see [Proposing a New Rule](http://eslint.org/docs/developer-guide/contributing/new-rules) for instructions."}}