# no-iterator

> Disallow the `__iterator__` property

No current engine looks at a property called `__iterator__`. An object that defines it isn't iterable, and `for (const song of playlist)` throws a `TypeError`. `for...of`, spread and destructuring call `[Symbol.iterator]` instead.

{/* 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]
"no-iterator" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad {"count": 2} */}
```js
Playlist.prototype.__iterator__ = function () {
  return new SongIterator(this);
};

const iterate = playlist["__iterator__"];
```

Not reported:

{/* good */}
```js
Playlist.prototype[Symbol.iterator] = function* () {
  yield* this.songs;
};

const iterate = playlist[Symbol.iterator];
```
