Skip to main content

no-confusing-set-methods

💼 This rule is enabled in the ✅ recommended config.

Disallows confusing methods for sets.

💭 This rule requires type information.

Specifically, this disallows the Set.keys and the Set.entries methods. These methods serve no purpose and should instead be replaced with the Set.values method (or implicit iteration if the set is being used inside of a for loop).

Rule Details​

// Bad
for (const key of mySet.keys()) {
}
for (const [key, value] of mySet.entries()) {
}

// Good
for (const value of mySet) {
}

Options​

This rule is not configurable.

Resources​