unicorn/no-unnecessary-array-flat-depth
Disallow passing 1 as the depth to Array#flat()
has suggestions
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#
example.js1 problem
const tags = posts.map(post => post.tags).flatPassing 1 as the depth argument is unnecessary.(1);example.jsNo problems
const tags = posts.map(post => post.tags).flat();
const leaves = tree.flat(2);
const everything = tree.flat(Infinity);