{"action":"created","issue":{"url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/issues/120","repository_url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn","labels_url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/issues/120/comments","events_url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/issues/120/events","html_url":"https://github.com/sindresorhus/eslint-plugin-unicorn/issues/120","id":272476069,"number":120,"title":"Prefer the spread operator over `Array.from()`","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars1.githubusercontent.com/u/170270?v=4","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"labels":[{"id":355209654,"url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":355209655,"url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-11-09T08:23:41Z","updated_at":"2018-05-05T15:55:46Z","closed_at":"2018-01-07T19:34:17Z","author_association":"OWNER","body":"## Fail\r\n\r\n```js\r\nconst set = new Set([1, 2]);\r\nArray.from(set).map(() => {});\r\n```\r\n\r\n## Pass\r\n\r\n```js\r\nconst set = new Set([1, 2]);\r\n[...set].map(() => {});\r\n```\r\n\r\nThe only difference between them is that `Array.from()` also works on array-like objects, while spread requires something to implement the iterator protocol, but we don't care about that, as it's what you should do anyway.\r\n\r\nShould be easy to make this auto-fixable.\r\n\r\nThere's already a built-in ESLint rule called [`prefer-spread`](https://eslint.org/docs/rules/prefer-spread), but it's only concerned about `.apply()`."},"comment":{"url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/issues/comments/386815139","html_url":"https://github.com/sindresorhus/eslint-plugin-unicorn/issues/120#issuecomment-386815139","issue_url":"https://api.github.com/repos/sindresorhus/eslint-plugin-unicorn/issues/120","id":386815139,"user":{"login":"bfred-it","id":1402241,"avatar_url":"https://avatars3.githubusercontent.com/u/1402241?v=4","gravatar_id":"","url":"https://api.github.com/users/bfred-it","html_url":"https://github.com/bfred-it","followers_url":"https://api.github.com/users/bfred-it/followers","following_url":"https://api.github.com/users/bfred-it/following{/other_user}","gists_url":"https://api.github.com/users/bfred-it/gists{/gist_id}","starred_url":"https://api.github.com/users/bfred-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfred-it/subscriptions","organizations_url":"https://api.github.com/users/bfred-it/orgs","repos_url":"https://api.github.com/users/bfred-it/repos","events_url":"https://api.github.com/users/bfred-it/events{/privacy}","received_events_url":"https://api.github.com/users/bfred-it/received_events","type":"User","site_admin":false},"created_at":"2018-05-05T15:55:46Z","updated_at":"2018-05-05T15:55:46Z","author_association":"NONE","body":"Why though? `[...var]` isn't better looking nor it does exactly the same thing. `Array.from` works on Array-likes while `...` only works on iterables."}}
{"actor":{"display_login":"bfred-it"}}