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.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"no-iterator" = "error" # or "warn"Examples#
example.js2 problems
Playlist.prototype.__iterator__Reserved name __iterator__. = function () {
return new SongIterator(this);
};
const iterate = playlist["__iterator__"]Reserved name __iterator__.;example.jsNo problems
Playlist.prototype[Symbol.iterator] = function* () {
yield* this.songs;
};
const iterate = playlist[Symbol.iterator];