---
title: "lint/complexity/no-iterator-to-array-in-foreach"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/complexity/no-iterator-to-array-in-foreach" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Report only.

## What it does

Detects `iterator_to_array()` calls used directly as a `foreach` expression.

## Configuration

```toml title="pun.toml"
[lint.rules]
"complexity/no-iterator-to-array-in-foreach" = "error"
```

To skip it in some files or lines, add an [override](/docs/configuration/pun-toml#lint) or an [ignore comment](/docs/configuration/ignore-comments).

## Replaces

- [`no-iterator-to-array-in-foreach`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-iterator-to-array-in-foreach) (mago-linter)

[More lint/complexity rules](/docs/rules/lint/complexity) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
