# no-unnecessary-array-flat-depth

Rule `unicorn/no-unnecessary-array-flat-depth`. Disallow using `1` as the `depth` argument of `Array#flat()`.

- Source: unicorn
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 12M weekly downloads of presets that enable it
- Trend: +40.1% last quarter
- Rank: #781 by reach, #977 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-unnecessary-array-flat-depth` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-unnecessary-array-flat-depth.md) |
| Oxlint | `unicorn/no-unnecessary-array-flat-depth` | no | safe | plugin `unicorn`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-flat-depth.html) |

## Code examples

### Incorrect: the rule reports this

```js
nested.flat(1);
// → [1, 2, 3, 4, [5]]
```

```js
const rows = [[1, 2], [3, 4]];
rows.flat(1);
```

```js
array?.flat(1);
```

### Correct: the rule accepts this

```js
nested.flat();
// → [1, 2, 3, 4, [5]]
```

```js
const rows = [[1, 2], [3, 4]];
rows.flat();
```

```js
const deeplyNested = [1, [2, [3, [4]]]];
deeplyNested.flat(2);
// → [1, 2, 3, [4]]
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-unnecessary-array-flat-depth": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/no-unnecessary-array-flat-depth": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-typeof-undefined](https://lintradar.dev/rules/unicorn/no-typeof-undefined.md): Disallow comparing `undefined` using `typeof`.
- [unicorn/no-unnecessary-array-splice-count](https://lintradar.dev/rules/unicorn/no-unnecessary-array-splice-count.md): Disallow using `.length` or `Infinity` as the `deleteCount` or `skipCount` argument of `Array#{splice,toSpliced}()`.
- [unicorn/no-this-assignment](https://lintradar.dev/rules/unicorn/no-this-assignment.md): Disallow assigning `this` to a variable.
- [unicorn/no-unnecessary-slice-end](https://lintradar.dev/rules/unicorn/no-unnecessary-slice-end.md): Disallow using `.length` or `Infinity` as the `end` argument of `{Array,String,TypedArray}#slice()`.
- [unicorn/no-object-as-default-parameter](https://lintradar.dev/rules/unicorn/no-object-as-default-parameter.md): Disallow the use of objects as default parameters.
- [unicorn/no-unreadable-array-destructuring](https://lintradar.dev/rules/unicorn/no-unreadable-array-destructuring.md): Disallow unreadable array destructuring.

---

Web page: https://lintradar.dev/rules/unicorn/no-unnecessary-array-flat-depth. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
