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

prefer-set-has: Add a minimumItems array length option #2491

Open
omril1 opened this issue Oct 28, 2024 · 1 comment
Open

prefer-set-has: Add a minimumItems array length option #2491

omril1 opened this issue Oct 28, 2024 · 1 comment

Comments

@omril1
Copy link

omril1 commented Oct 28, 2024

Description

Add a minimumItems option so only arrays from a certain known size will be linted (default 0).

The rule can sometimes be too strict, using sets over arrays is usually more performant the more elements it has, and it's negligible in small numbers and readability is preferred.

Fail

minimumItems: 5

const array = [1, 2, 3, 4, 5, 6, 7];
const hasValue = value => array.includes(value);

Pass

minimumItems: 5

const array = [1, 2];
const hasValue = value => array.includes(value);
@sindresorhus
Copy link
Owner

Accepted.

The option should be called minimumItems.

@omril1 omril1 changed the title prefer-set-has: Add a min array length option prefer-set-has: Add a minimumItems array length option Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants