Skip to content

chore(mosaic): enable stricter type-safety and hooks lint rules - #10122

Merged
alexcarpenter merged 2 commits into
mainfrom
carp/mosaic-strict-rules
Oct 8, 2026
Merged

alexcarpenter merged 2 commits into
mainfrom
carp/mosaic-strict-rules

Conversation

@alexcarpenter

@alexcarpenter alexcarpenter commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Description

Turns on the stricter rules Fredrik flagged as errors in the packages/mosaic lint block: no-explicit-any, the five no-unsafe-* rules, ban-ts-comment, no-floating-promises, no-misused-promises, await-thenable, only-throw-error, prefer-promise-reject-errors, use-unknown-in-catch-callback-variable, react-hooks/rules-of-hooks and react-hooks/exhaustive-deps.

Hits are fixed at the source. No new bulk suppressions; the create-actor.ts assertion count drops from 9 to 8.

  • utils/errors.ts, password errors: read API errors through the typed ClerkAPIError interface instead of the class, whose meta defaults to any. The picture and organization logo controllers use a new toGlobalError.
  • css-vars.ts: narrow floating-ui's untyped alignSelectedItem middleware data from unknown.
  • use-reverification-with-state.ts: the fetcher type is derived from useReverification's parameter instead of restating its any constraint.
  • use-in-view.ts: observer options are read from the latest-params ref, like onChange already was, so the ref callback stays stable.
  • create-actor.ts, jest-dom.d.ts: any replaced with unknown.

Five disables remain, each with a reason:

  • user-button.tsx (x2): appearance from @clerk/shared is an unresolved type until a framework augments ClerkAppearanceRegistry. It is passed through untouched.
  • use-mosaic-environment.ts: __internal_environment is implemented by clerk-js but not declared on the shared Clerk type. The existing @ts-expect-error stays, and no-unsafe-return is disabled on the same line because that access is untyped.
  • machine/types.ts: invoke needs a per-state output type. With unknown, typed onDone handlers fail to compile (checked with tsc).
  • use-render.tsx: the ref on render props. This was already an intentional any with a SAFETY comment; the reason moved into the directive.

Behavior changes

  • useInView reads root, rootMargin and threshold when the observed element attaches, instead of from the first render. The only caller (use-organization-list-in-view.ts) passes a constant threshold: 0, so it behaves the same.

react/jsx-no-leaked-render is left out. It is not type-aware, and all 10 sites it flagged were false positives, mostly && inside props rather than children.

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:

@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b8965bd

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

@vercel

vercel Bot commented Oct 7, 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 Oct 8, 2026 7:39pm UTC
swingset Ready Ready Preview Oct 8, 2026 7:39pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 62dea455-73b8-48eb-9e7b-425815e8c8ed
📥 Commits

Reviewing files that changed from the base of the PR and between e2d2828 and b8965bd.

📒 Files selected for processing (2)
  • packages/mosaic/src/features/organization-profile/organization-profile-profile-section/organization-profile-logo.controller.ts
  • packages/mosaic/src/hooks/use-mosaic-environment.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Limit details: You’ve used all 4 included reviews currently available. Your 68 included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.


📝 Walkthrough

Walkthrough

The PR enables additional ESLint rules for packages/mosaic and updates TypeScript types, annotations, and suppressions. The in-view hook reads the latest options from a ref. CSS variable generation validates aligned-height data before using it. The errors utility replaces toFormError with toGlobalError, which profile controllers use for caught failures.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: austincalvelage

Merge Risk: ⚪ Minimal · up to b8965

The inspected error, observer, and layout paths retain their existing behavior. No concrete user-facing regression remains to resolve before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description directly explains the stricter lint rules, source fixes, remaining suppressions, and reported behavior impact. It is related to the changeset.
Title check ✅ Passed The title clearly and concisely identifies the main change: enabling stricter type-safety and React Hooks lint rules in Mosaic.
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10122

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10122

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10122

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10122

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10122

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10122

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10122

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10122

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10122

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10122

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10122

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10122

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10122

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10122

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10122

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10122

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10122

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10122

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10122

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10122

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10122

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10122

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10122

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10122

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10122

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10122

commit: b8965bd

@Ephem Ephem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on all of these!

Comment thread packages/mosaic/src/hooks/use-mosaic-environment.ts Outdated
@alexcarpenter
alexcarpenter merged commit 8fb4989 into main Oct 8, 2026
53 checks passed
@alexcarpenter
alexcarpenter deleted the carp/mosaic-strict-rules branch October 8, 2026 20:12

This branch was successfully deployed

2 active deployments
Preview – swingset — b8965bdc Deployed Oct 8, 2026 by vercel[bot]
Preview – clerk-js-sandbox — b8965bdc Deployed Oct 8, 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