Skip to main content

no-confusing-set-methods

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 and Defaults

{
"rules": {
"complete/no-confusing-set-methods": "error"
}
}

This rule is not configurable.

Resources