You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ratchets): catch aliased, helper-called and re-exported component calls and prop writes in the phone compiler hazard rules - #52876
#51418 added two lint rules that stop the phone app's React Compiler build from crashing or showing stale data. One catches components called like plain functions; the other catches code writing into what a component was given. Both rules only saw the exact form of the original bug. This teaches them the other common forms, so the same mistake can't come back in another form.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$217
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$217
Prod
5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$563
$\color{#cf222e}{\Huge{\mathbf{−}}}$184
$\color{#1a7f37}{\Huge{\mathbf{+}}}$379
What Changed
Before, the mobile React Compiler hazard ratchet missed three shapes. I confirmed each on fresh main, with all three probes present, the ratchet reported 0:
Renamed imports: a component called under an import alias or a default import.
Components called from helpers: a component called through a helper during render.
Prop writes: writes like model.x = … into a prop or hook argument during render.
Now each module's own components and helpers are resolved, and imports follow what their module actually exports:
Component calls: a component counts when called during render under an alias, as a default import (anonymous default exports included), as a namespace import (K.Child()), through an @/ import (the alias in mobile/tsconfig.json), or through a helper. The helper can be in the same module or come through an export { } list, a re-export or export *.
A "component" is a function that renders JSX or calls a hook while it runs, so capitalised factories don't count.
A component written as a PascalCase arrow, or an anonymous default export that returns another component's call, counts too.
Helper calls inside timer or handler callbacks don't count.
Prop writes: writes into a prop or hook argument during render count. That covers every assignment operator, ++/-- and delete, and sees through casts and !.
These are not counted: ref .current (also ['current']), Reanimated .value, writes in callbacks and effects, rest copies, and locals that shadow the argument.
Object.assign onto an argument now also counts only during render.
Fixture test: a new check-mobile-react-compiler-hazard-ratchet.test.mjs runs the real collector on throwaway git repos, one case per gap. Every case fails against main's ratchet.
File layout: the rules and the shared module-graph helpers moved to react-compiler-render-ownership-hazards.mjs and mobile-module-graph.mjs, to keep the ratchet under the 600-line limit. Changed-check selection runs the collector and its fixtures when either file changes. scopeDeclares is now exported from render-path-translate.mjs for binding resolution.
The ratchet still reports 0 on the app.
Why
Resolving each module's real bindings, rather than matching component names across all files, keeps the rules precise. An unrelated factory that shares a component's name no longer counts, and an aliased or re-exported component no longer slips through. Limiting writes to render time matches what the compiler actually breaks on: a handler writing into a mutable store argument is fine.
The ratchet reports 0 on the current app. A reviewer compared the old and new rules across all 3,204 scanned files: no app call site was gained or lost.
pnpm check:changed passes.
Performance
Build-time only. The collector takes about 2.0–2.4 s on the app, against about 1.6–2.1 s before: one extra pass over the module graph that settles in 3 iterations. No runtime cost.
Risk
A false positive blocks a PR at lint time until the code is changed or the rule is fixed. The rules report 0 on today's app, and their exemptions are covered by fixtures. A plain revert restores the previous rules.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Known limits, none present in the app today:
export * as NS from re-exports aren't followed.
require() imports aren't followed.
A component called inside a closure passed to an arbitrary function isn't counted. Only known synchronous callers (array methods, an immediately-run function, memo hooks) count, so timer callbacks are skipped.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
… prop writes in the compiler hazard rules
The rules added in #51418 missed a component called under an import alias or
as a default import, a component called through a helper (here or in another
module) during render, and writes like model.x = ... into a prop or hook
argument during render. All three now count, with a fixture case each; ref
.current, Reanimated .value and writes inside callbacks or effects do not.
The rules and the shared module-graph helpers move to their own files to keep
the ratchet under the line limit.
… and resolve prop writes by binding
Component seeds are now functions that render JSX or call hooks, so a
capitalized factory no longer spreads through helpers. Export lists,
re-exports, export * and namespace imports carry component callers across
modules, and anonymous default-exported components count. Prop writes unwrap
casts and non-null assertions, cover every assignment operator, read literal
element keys (ref['current']), and are attributed by the identifier's real
binding, so a shadowing local or a rest copy is not the argument. Changed-check
selection runs the collector and its fixtures when either extracted module
changes.
…nchronous render-time calls
Component seeds are each module's own functions that render JSX or call hooks
(React.useX too) while they run, and imports resolve through what their module
exports, so a factory sharing a component's name elsewhere no longer counts.
Helper propagation follows namespace calls and skips timer or handler
callbacks, and Object.assign onto an argument counts only during render. The
write fixtures split into counted and uncounted files.
…t components that call a component
The phone app's tsconfig maps @/* to src/*, so module resolution follows it
(this also covers the theme and language wrapper rule). A component written as
a PascalCase arrow or an anonymous default export that returns another
component's call now counts, as a named function declaration already did.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
The pull request exports scopeDeclares without changing its behavior. It adds mobile module-graph utilities and React Compiler render-ownership hazard analysis. The ratchet uses the new analysis to detect component calls during render and writes to React function parameters. New tests cover detected and excluded cases. Changed-check selection now associates the shared analysis modules with the ratchet check.
Merge Risk: Low · previous review af7c8
This extends a lint-time ratchet. A few rare code patterns could be wrongly flagged and block a PR, and the check now takes a few hundred milliseconds longer. There is no production impact, and a revert is simple, so the merge risk is low.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the mobile React Compiler hazard ratchet now catches aliased, helper-called and re-exported component calls and prop writes. It matches the changeset and objectives. T…
Description check
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing, Performance, Risk with level, Agent skill upstream boundary…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the mobile React Compiler hazard ratchet now catches aliased, helper-called and re-exported component calls and prop writes. It matches the changeset and objectives. The title is long (126 characters) and dense, but it is specific and on topic.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing, Performance, Risk with level, Agent skill upstream boundary, Notes, and Checklist. Its content matches the objectives and the file summaries. The Linked Issue section says there is no issue, only a follow-up to #51418. The AI Disclosure section is empty, and the template's rule for that section applies to internal contributors only. The Performance section is filled in. The Testing section has checkboxes and details.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Treat case and default clauses as one lexical scope in… · render-path-translate.mjs:261-267
config/scripts/localization/reactive-translate/render-path-translate.mjs:261-267 Minor · Functional Correctness · Quick win
Treat case and default clauses as one lexical scope in scopeDeclares.
scopeDeclares checks each CaseClause and DefaultClause only against its own statements. A switch shares one block scope across all its clauses, so a let or const declared in one clause is visible in the others. isOwnerParameter walks up from the identifier and stops at the first scope that declares the name. Within a switch, that walk misses a binding declared in a sibling clause, then matches the function parameter. A write to the switch-scoped local is then reported as a write to the parameter. The PR's stated exclusion for shadowing locals does not hold for this case.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
…t exports, rest arrays, refs and props
Seeds are module-level components only. A lowercase named default export that
renders counts. Writes into a rest-parameter array, or through a ref's
.current, don't count, while a component's own props.value or props.current
does. Object.assign into a member of an argument counts like a member write.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
#51418 added two lint rules that stop the phone app's React Compiler build from crashing or showing stale data. One catches components called like plain functions; the other catches code writing into what a component was given. Both rules only saw the exact form of the original bug. This teaches them the other common forms, so the same mistake can't come back in another form.
What Changed
Before, the mobile React Compiler hazard ratchet missed three shapes. I confirmed each on fresh main, with all three probes present, the ratchet reported 0:
model.x = …into a prop or hook argument during render.Now each module's own components and helpers are resolved, and imports follow what their module actually exports:
K.Child()), through an@/import (the alias inmobile/tsconfig.json), or through a helper. The helper can be in the same module or come through anexport { }list, a re-export orexport *.++/--anddelete, and sees through casts and!..current(also['current']), Reanimated.value, writes in callbacks and effects, rest copies, and locals that shadow the argument.Object.assignonto an argument now also counts only during render.check-mobile-react-compiler-hazard-ratchet.test.mjsruns the real collector on throwaway git repos, one case per gap. Every case fails against main's ratchet.react-compiler-render-ownership-hazards.mjsandmobile-module-graph.mjs, to keep the ratchet under the 600-line limit. Changed-check selection runs the collector and its fixtures when either file changes.scopeDeclaresis now exported fromrender-path-translate.mjsfor binding resolution.The ratchet still reports 0 on the app.
Why
Resolving each module's real bindings, rather than matching component names across all files, keeps the rules precise. An unrelated factory that shares a component's name no longer counts, and an aliased or re-exported component no longer slips through. Limiting writes to render time matches what the compiler actually breaks on: a handler writing into a mutable store argument is fine.
Linked Issue
Follow-up to #51418. No issue filed.
Visual Proof
N/A: build-time lint only, no app change.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
The fixture test has 3 cases: component calls, helpers, writes. All pass, and all fail against main's ratchet.
The original fix(mobile): stop the Tasks page crashing on phones since the React Compiler build #51418 shape (
return MobileTasksLegacySurface({ model })plusObject.assign(model, …)) is still counted.The ratchet reports 0 on the current app. A reviewer compared the old and new rules across all 3,204 scanned files: no app call site was gained or lost.
pnpm check:changedpasses.Performance
Build-time only. The collector takes about 2.0–2.4 s on the app, against about 1.6–2.1 s before: one extra pass over the module graph that settles in 3 iterations. No runtime cost.
Risk
A false positive blocks a PR at lint time until the code is changed or the rule is fixed. The rules report 0 on today's app, and their exemptions are covered by fixtures. A plain revert restores the previous rules.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Known limits, none present in the app today:
export * as NS fromre-exports aren't followed.require()imports aren't followed.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)