Skip to content

chore(mosaic): lint clock reads during render - #10641

Open
alexcarpenter wants to merge 1 commit into
carp/mosaic-timingfrom
carp/mosaic-no-render-clock
Open

alexcarpenter wants to merge 1 commit into
carp/mosaic-timingfrom
carp/mosaic-no-render-clock

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Description

Adds a mosaic/no-render-clock lint rule that flags Date.now() and new Date() when they run during render: in a component or hook body, or in a useState, useMemo or useRef initializer. The message points to useNow, so these reads go through MosaicNowProvider and the server and client agree. Reads in effects, event handlers, useCallback and machine actions are still allowed, and so is a parsed date like new Date(value).

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other: lint rule

@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 4, 2026 12:42pm UTC
swingset Ready Ready Preview Nov 4, 2026 12:42pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bc07817

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@blacksmith-sh

blacksmith-sh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Matches Render-time clock reads are flagged

All six render-time reads (component body, hook body, useState, useMemo, useRef, forwardRef) are flagged with the useNow message after; none were flagged by this rule before.

Render-read probe source

Merge-base

Lint before

This PR bc07817a

Lint after

Also checked · 2 match

Matches Non-render reads still allowed
Matches Clock owners and tests exempt

Proof on bc07817a · Did Proof get it right? Yes · No

View full Proof report

This branch was successfully deployed

2 active deployments
Preview – swingset — bc07817a Deployed Nov 4, 2026 by vercel[bot]
Preview – clerk-js-sandbox — bc07817a Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants