no-shared-mutable-zod-default
Return a fresh mutable value from each Zod default factory.
Why
Zod 4 returns function defaults directly. A factory returning one captured mutable object lets one parsed result mutate defaults observed by later parses.
Fix
Allocate a fresh array, object or collection in the factory. Preserve any intended immutable shared values; do not blindly introduce a shallow clone for nested state.
Examples
import { z } from "zod/v4";const shared = [];z.array(z.string()).default(() => shared);import { z } from "zod/v4";z.array(z.string()).default(() => []);