{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/6316","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/6316/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/6316/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/6316/events","html_url":"https://github.com/eslint/eslint/issues/6316","id":158272710,"number":6316,"title":"ESLint fails to detect all arguments of a function as defined but never used","user":{"login":"plumlee","id":136463,"avatar_url":"https://avatars.githubusercontent.com/u/136463?v=3","gravatar_id":"","url":"https://api.github.com/users/plumlee","html_url":"https://github.com/plumlee","followers_url":"https://api.github.com/users/plumlee/followers","following_url":"https://api.github.com/users/plumlee/following{/other_user}","gists_url":"https://api.github.com/users/plumlee/gists{/gist_id}","starred_url":"https://api.github.com/users/plumlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plumlee/subscriptions","organizations_url":"https://api.github.com/users/plumlee/orgs","repos_url":"https://api.github.com/users/plumlee/repos","events_url":"https://api.github.com/users/plumlee/events{/privacy}","received_events_url":"https://api.github.com/users/plumlee/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/question","name":"question","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-03T01:16:51Z","updated_at":"2016-06-03T02:09:12Z","closed_at":"2016-06-03T02:09:12Z","body":"**What version of ESLint are you using?**\r\n2.9.x, also tested with 2.11.x using npm link. Using eslint as part of xo@0.15.1.\r\n\r\n**What parser (default, Babel-ESLint, etc.) are you using?**\r\nBabel-ESLint I believe - the issue I’ve seen is using xo@0.15.1.\r\n\r\n**Please show your full configuration:**\r\nUsing config via xo:\r\n\r\n    \"space\": true,\r\n    \"envs\": [\r\n        \"browser\"\r\n    ]\r\n\r\n**What did you do? Please include the actual source code causing the issue.**\r\n\r\nThis is part of a Mocha+Chai+Expect test spec where I see the issue:\r\n\r\n```\r\n    it('should convert the arguments of a function to an array', function () {\r\n      var testFn = function (a, b, c) {\r\n        return utils.toArray(arguments);\r\n      };\r\n      expect(testFn(1, 2, 3)).to.deep.equal([1, 2, 3]);\r\n    });\r\n```\r\n\r\nRunning xo and thus eslint as above outputs:\r\n`error  'c' is defined but never used  no-unused-vars`\r\n\r\nRemove the third argument:\r\n```\r\n    it('should convert the arguments of a function to an array', function () {\r\n      var testFn = function (a, b) {\r\n        return utils.toArray(arguments);\r\n      };\r\n      expect(testFn(1, 2)).to.deep.equal([1, 2]);\r\n    });\r\n```\r\n\r\nRun as above outputs:\r\n`error  ‘b' is defined but never used  no-unused-vars`\r\n\r\nAnd then the same if you take it all the way down to just `a`.\r\n\r\n**What did you expect to happen?**\r\n\r\nI expect eslint to detect all function arguments are defined but never used. ESLint appears to be detecting only the last item in the function arguments, regardless of the number of arguments. This makes me suspect that the issue is either a RegExp failing to match properly or something iterating through function arguments but failing to properly increment and capture errors.\r\n\r\n**What actually happened? Please include the actual, raw output from ESLint.**\r\nSee above.\r\n\r\nI’m happy to start digging into the code and do a PR if someone can point me in the right direction as to where to start."},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/223473559","html_url":"https://github.com/eslint/eslint/issues/6316#issuecomment-223473559","issue_url":"https://api.github.com/repos/eslint/eslint/issues/6316","id":223473559,"user":{"login":"ilyavolodin","id":1380062,"avatar_url":"https://avatars.githubusercontent.com/u/1380062?v=3","gravatar_id":"","url":"https://api.github.com/users/ilyavolodin","html_url":"https://github.com/ilyavolodin","followers_url":"https://api.github.com/users/ilyavolodin/followers","following_url":"https://api.github.com/users/ilyavolodin/following{/other_user}","gists_url":"https://api.github.com/users/ilyavolodin/gists{/gist_id}","starred_url":"https://api.github.com/users/ilyavolodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilyavolodin/subscriptions","organizations_url":"https://api.github.com/users/ilyavolodin/orgs","repos_url":"https://api.github.com/users/ilyavolodin/repos","events_url":"https://api.github.com/users/ilyavolodin/events{/privacy}","received_events_url":"https://api.github.com/users/ilyavolodin/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T02:09:12Z","updated_at":"2016-06-03T02:09:12Z","body":"This is correct behavior. While none of the arguments are used, in a lot of cases, you have to specify a few unused arguments to get to the one you want to use. For example, in a lot of cases, callback signatures, but you only want to use 3-rd one. Unless you use `arguments` property, you have no way to only declare one parameter and expect it to get 3-rd value passed into the function.\r\nThis is configurable and is controlled by `args` option of the rule (http://eslint.org/docs/rules/no-unused-vars#args). If you want all parameters to be checked, you can configure the rule in the following matter:\r\n```js\r\n\"no-unused-vars\": [\"error\", { \"args\": \"all\" }]\r\n```\r\nThis will force the rule to check all arguments.\r\n\r\nClosing, as this is behaving as expected. Feel free to reopen if you disagree."}}
{"actor":{"display_login":"ilyavolodin"}}