Skip to content

Prefer using Set#size instead of Array#length ​

💼 This rule is enabled in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

Prefer using Set#size directly instead of first converting it to an array and then using its .length property.

Fail ​

js
function isUnique(array) {
	return [...new Set(array)].length === array.length;
}

Pass ​

js
function isUnique(array) {
	return new Set(array).size === array.length;
}

Released under the Apache License 2.0.