no-useless-collection-argument
March 27, 2026 ยท View on GitHub
๐ Disallow useless values or fallbacks in Set, Map, WeakSet, or WeakMap.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ง๐ก This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.
It's unnecessary to pass an empty array or string when constructing a Set, Map, WeakSet, or WeakMap, since they accept nullish values.
It's also unnecessary to provide a fallback for possible nullish values.
Examples
// โ
const set = new Set([]);
// โ
const set = new Set("");
// โ
const set = new Set();
// โ
const set = new Set(foo ?? []);
// โ
const set = new Set(foo ?? "");
// โ
const set = new Set(foo);