Sometimes a hardcoded Set
grows large enough for it to be hard to see if there is already a value in it. One could miss that a value one wants to add is already there and add a duplicate.
This rule should at minimum report hardcoded sets of literals and const
s with duplicates.
This rule may also report consecutive .add
calls with same arguments (this is probably much harder to implement). Or maybe this could be a separate rule like unicorn/no-array-push-push
.
const allowed = new Set([
'foo',
'bar',
'buz',
'qux',
'bar', // ← Remove duplicate value `'bar'` from the Set
]);
const allowed = new Set([
'foo',
'bar',
'buz',
'qux',
]);
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too