Linter · Rules
unicorn/no-unnecessary-array-flat-depth
Disallow passing 1 as the depth to Array#flat()
flat() flattens one level by default, so the 1 in flat(1) does nothing.
--fix-suggestions removes the argument.
Configure
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/no-unnecessary-array-flat-depth" = "error" # or "warn"
Examples
Reported:
const tags = posts.map(post => post.tags).flat(1);
Not reported:
const tags = posts.map(post => post.tags).flat();
const leaves = tree.flat(2);
const everything = tree.flat(Infinity);