arrayFlatUnnecessaryDepths
Reports using
1as 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().
Examples
Section titled “Examples”declare const array: number[][];array.flat(1);declare const array: number[][] | undefined;array?.flat(1);declare const array: number[][];array.flat();declare const array: number[][][];array.flat(2);declare const array: number[];array.flat(Infinity);Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you prefer to be explicit about the depth argument for readability or consistency, you may disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.