no-unnecessary-array-flat-depth

March 27, 2026 ยท View on GitHub

๐Ÿ“ Disallow using 1 as the depth argument of Array#flat().

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

Passing 1 as the depth argument to Array#flat(depth) is unnecessary.

Examples

// โŒ
foo.flat(1);

// โœ…
foo.flat();
// โŒ
foo?.flat(1);

// โœ…
foo?.flat();