Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule proposal: prefer-set-size #1700

Closed
fisker opened this issue Jan 20, 2022 · 1 comment · Fixed by #1952
Closed

Rule proposal: prefer-set-size #1700

fisker opened this issue Jan 20, 2022 · 1 comment · Fixed by #1952

Comments

@fisker
Copy link
Collaborator

fisker commented Jan 20, 2022

Description

Come up with the idea because I wrote something stupid. https://github.com/sindresorhus/globby/blob/51c8f68e63dc7a49f986bd0751e3488ced7485ec/tests/globby.js#L301

Fail

const set = new Set(foo);
const length = [...set].length;
const uniqueLength = [...new Set(array)].length

Pass

const set = new Set(foo);
const {size} = set;
const uniqueLength = new Set(array).size;
@sindresorhus
Copy link
Owner

Accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants