Skip to content

arrayFlatUnnecessaryDepths

Reports using 1 as the depth argument of .flat() since it is the default.

✅ This rule is included in the ts stylistic presets.

The default depth for Array.prototype.flat() is 1, so passing it explicitly is redundant. This rule reports when 1 is passed as the depth argument to .flat().

declare const array: number[][];
array.flat(1);
declare const array: number[][] | undefined;
array?.flat(1);

This rule is not configurable.

If you prefer to be explicit about the depth argument for readability or consistency, you may disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.