{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/7654","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/7654/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/7654/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/7654/events","html_url":"https://github.com/eslint/eslint/issues/7654","id":191617702,"number":7654,"title":"`comma-dangle` warning for destructuring assignment when skipping the last entry","user":{"login":"philer","id":4589347,"avatar_url":"https://avatars.githubusercontent.com/u/4589347?v=3","gravatar_id":"","url":"https://api.github.com/users/philer","html_url":"https://github.com/philer","followers_url":"https://api.github.com/users/philer/followers","following_url":"https://api.github.com/users/philer/following{/other_user}","gists_url":"https://api.github.com/users/philer/gists{/gist_id}","starred_url":"https://api.github.com/users/philer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philer/subscriptions","organizations_url":"https://api.github.com/users/philer/orgs","repos_url":"https://api.github.com/users/philer/repos","events_url":"https://api.github.com/users/philer/events{/privacy}","received_events_url":"https://api.github.com/users/philer/received_events","type":"User","site_admin":false},"labels":[{"id":45711354,"url":"https://api.github.com/repos/eslint/eslint/labels/triage","name":"triage","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-25T03:12:27Z","updated_at":"2016-11-25T03:17:21Z","closed_at":null,"body":"(I'll take the liberty of restructuring your template as it makes no sense to describe the actual problem below my entire configuration…)\r\n\r\nDestructuring array assignment offers the possibility to [skip/ignore values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values). In my particular use case I want to **skip the *last* entry** of an array with a fixed length of 2.\r\n\r\nEasiest way to reproduce:\r\n```js\r\nconst [a,] = [1,2]; // warning  Unexpected trailing comma  comma-dangle\r\n```\r\nMy personal use case (part of a minimalistic Set implementation):\r\n```js\r\ncontains() {\r\n  const [found,] = this.search(x); // returns an array like [true, 5] or [false, -1]\r\n  return found;\r\n}\r\n```\r\n**Note:** I am aware that I could use `return this.search(x)[0];` instead. However I still believe that this should be possible to use as expected and I assume there will be other use cases that actually require it.\r\n\r\n**Note 2:** Obviously this common pattern from other languages doesn't work either: \r\n```const [a,_] = [1,2]; // error    '_' is defined but never used  no-unused-vars```\r\n\r\n**What did you expect to happen?**\r\nESLint doesn't complain as this dangling comma actually has meaning.\r\n\r\n**What actually happened? Please include the actual, raw output from ESLint.**\r\n```  54:17  warning  Unexpected trailing comma  comma-dangle```\r\n\r\n------------------\r\n\r\n* **ESLint Version:** v3.6.1\r\n* **Node Version:** v6.9.1\r\n* **npm Version:** 3.10.8\r\n\r\n* **Using `babel-parser`**.\r\n\r\n`.eslintrc.json`:\r\n```json\r\n{\r\n  \"root\": true,\r\n  \"extends\": \"eslint:recommended\",\r\n  \"parserOptions\": {\r\n    \"sourceType\": \"module\"\r\n  },\r\n  \"rules\": {\r\n    \"block-scoped-var\": \"warn\",\r\n    \"comma-dangle\": [\r\n      \"warn\",\r\n      \"always-multiline\"\r\n    ],\r\n    \"no-console\": \"off\",\r\n    \"no-var\": \"warn\",\r\n    \"semi\": [\r\n      \"error\",\r\n      \"always\"\r\n    ],\r\n    \"strict\": \"error\",\r\n    \"no-cond-assign\": \"off\"\r\n  },\r\n  \"env\": {\r\n    \"browser\": true\r\n  },\r\n  \"globals\": {\r\n    \"require\": true,\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/262873253","html_url":"https://github.com/eslint/eslint/issues/7654#issuecomment-262873253","issue_url":"https://api.github.com/repos/eslint/eslint/issues/7654","id":262873253,"user":{"login":"not-an-aardvark","id":11638619,"avatar_url":"https://avatars.githubusercontent.com/u/11638619?v=3","gravatar_id":"","url":"https://api.github.com/users/not-an-aardvark","html_url":"https://github.com/not-an-aardvark","followers_url":"https://api.github.com/users/not-an-aardvark/followers","following_url":"https://api.github.com/users/not-an-aardvark/following{/other_user}","gists_url":"https://api.github.com/users/not-an-aardvark/gists{/gist_id}","starred_url":"https://api.github.com/users/not-an-aardvark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/not-an-aardvark/subscriptions","organizations_url":"https://api.github.com/users/not-an-aardvark/orgs","repos_url":"https://api.github.com/users/not-an-aardvark/repos","events_url":"https://api.github.com/users/not-an-aardvark/events{/privacy}","received_events_url":"https://api.github.com/users/not-an-aardvark/received_events","type":"User","site_admin":false},"created_at":"2016-11-25T03:17:21Z","updated_at":"2016-11-25T03:17:21Z","body":"Thanks for the issue. However, I don't think I understand what the problem is. Regardless of how long the array actually is, the dangling comma isn't doing anything, so you can just omit it:\r\n\r\n```js\r\ncontains() {\r\n  const [found] = this.search(x); // returns an array like [true, 5] or [false, -1]\r\n  return found;\r\n}\r\n```"}}
{"actor":{"display_login":"not-an-aardvark"}}