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);