Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 818 Bytes

File metadata and controls

26 lines (18 loc) · 818 Bytes

prefer-set-size

📝 Prefer using Set#size instead of Array#length.

💼 This rule is enabled in the following configs: ✅ recommended, ☑️ unopinionated.

🔧 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.

Examples

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

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