An array method's callback is never run on the empty slots of Array(n)
What it finds
new Array(5).map((_, i) => i): Array(n) makes an array of n holes, and map, forEach, filter and the other callback methods skip holes, so the callback never runs and the result is again five holes. Array.from({ length: 5 }, (_, i) => i) or new Array(5).fill(0).map(...) do what was meant.
Array must be the global one, called with a single argument that is not an array or string literal.
From the rule's source, callback_over_holes.rs.
function indexes(n: number) { const a = new Array(n).map((_, i) => i);tx0 reports: map skips the empty slots that Array(n) creates const b = Array(3).forEach((x) => x);tx0 reports: forEach skips the empty slots const c = new Array(n).fill(0).map((_, i) => i); const d = Array.from({ length: n }, (_, i) => i); const e = new Array("a").map((x) => x); return [a, b, c, d, e];} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:callback-over-holes" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:callback-over-holes] reason="..."tx0 explain tx0/ts:callback-over-holes shows the same in the terminal. Found a false positive? Report it.