Background
Per immutability.spec.diff.md, the current immutability rule does not detect mutations on for-of iterator variables, even when the iterated collection comes from props or state.
Current behavior
function Component({ items }) {
for (const x of items) {
x.modified = true; // ❌ currently missed
}
}
Expected behavior
When the right-hand side of a for-of (e.g. items) is identified as coming from props or state, treat the left-hand iterator variable (e.g. x) as an immutable object and flag mutations on it.
References
Priority
P2 — medium implementation cost, covers a common indirect mutation pattern.
Background
Per
immutability.spec.diff.md, the currentimmutabilityrule does not detect mutations onfor-ofiterator variables, even when the iterated collection comes from props or state.Current behavior
Expected behavior
When the right-hand side of a
for-of(e.g.items) is identified as coming from props or state, treat the left-hand iterator variable (e.g.x) as an immutable object and flag mutations on it.References
plugins/eslint-plugin-react-x/src/rules/immutability/immutability.spec.diff.md(§8 / §9 Key Gaps feat(eslint-plugin): add jsx/no-script-url #7)ValidateNoFreezingKnownMutableFunctionsPriority
P2 — medium implementation cost, covers a common indirect mutation pattern.