Skip to content

no-table-create-map

Reports .map(...) called directly on table.create(...) or new Array(...).

The rule only looks for the direct pattern. These are reported:

  • table.create(...).map(...)
  • new Array(...).map(...)

It does not report cases where you store the result first, add another method call before map, or shadow table or Array with your own local definitions.

For new Array(...), the rule only matches constructors with one or two arguments.

Incorrect
const mapped = table.create(total, fallback).map((value) => value);
const rewards = new Array<Reward>(size).map(() => makeReward());
Correct
const rewards = new Array<Reward>(size);
for (const index of $range(1, size)) {
rewards[index - 1] = makeReward();
}
const baseRewards = table.create(size, fallback);
const mappedRewards = baseRewards.map((value) => value);

This rule has no options.