Skip to content

[purity] Remove new Date(arg) exception to align with React Compiler spec #1759

@Rel1cx

Description

@Rel1cx

Background

Per purity.spec.diff.md, the current purity rule exempts new Date(arg) (Date constructor with arguments) from impurity detection, treating it as deterministic.

React Compiler's ValidateNoImpureValuesInRender treats all new Date() calls as impure (non-deterministic).

Current behavior

// Currently allowed by the ESLint rule (but flagged by the SPEC)
const date = new Date('2024-01-01'); // ❌ should be flagged

Expected behavior

Remove the argument-length check for new Date so that new Date(arg) is treated as impure, just like new Date().

References

  • Diff report: plugins/eslint-plugin-react-x/src/rules/purity/purity.spec.diff.md (§5 Special Cases)
  • SPEC: ValidateNoImpureValuesInRender

Priority

P0 — very low implementation cost (remove a conditional branch), high alignment benefit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerReact Compiler SPEC alignmentpriority: criticalRegression or crash; fix immediatelystatus: triageNeeds initial review / classificationtype: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions