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 and stylisticStrict 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
const array: number[][]
array
: number[][];
const array: number[][]
array
.
Array<number[]>.flat<number[][], 1>(this: number[][], depth?: 1 | undefined): number[]

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.

@paramdepth The maximum recursion depth

flat
(1);
declare const
const array: number[][] | undefined
array
: number[][] | undefined;
const array: number[][] | undefined
array
?.
Array<number[]>.flat<A, D>(this: A, depth?: D | undefined): FlatArray<A, D>[]

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.

@paramdepth The maximum recursion depth

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 ❤️‍🔥 around the world by the Flint team and contributors.