# unicorn/no-magic-array-flat-depth

> Disallow an unexplained number as the depth of `.flat()`

Someone reading `rows.flat(3)` can't tell why the depth is 3, or whether it was picked to mean "all the way down". Say why in a comment, give the number a name, or use `Infinity` to flatten every level.

A depth of `1` is allowed, because it's the default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/no-magic-array-flat-depth" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
const cells = tables.flat(2);
```

Not reported:

{/* good */}
```js
const cells = tables.flat(2 /* table, then row */);

const TABLE_DEPTH = 2;
const sameCells = tables.flat(TABLE_DEPTH);

const leaves = tree.flat(Infinity);
const rows = tables.flat(1);
```
