MIL-1559: no-giant-component flags non-React TypeScript modules - #525
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Member
Author
|
bugbot run |
Co-authored-by: Cursor <cursoragent@cursor.com>
no-giant-component flags non-React TypeScript modules
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
Catches false positives where
react-doctor/no-giant-componenttreated large PascalCase helpers as React components even when they did not render React output.The rule previously used a name-and-size heuristic: any oversized PascalCase function declaration or PascalCase function assignment could be reported as a component. That was too broad for service modules, adapters, and data helpers that happen to use PascalCase naming. The rule should only warn when the oversized candidate is actually component-shaped, so this change requires direct React render evidence before reporting.
RDE validation was run against the first 1000 distinct repos from
repos.json, expanding to 4350 rootDir scans. Both baseline and this branch produced 0react-doctor/no-giant-componentdiagnostics, parity diff was[], and no false positives were found.What changed?
react-doctor/no-giant-componentso oversized PascalCase function candidates must contain direct React render output before they are reported.import { createElement } from "react", and React default/namespace imports used asReact.createElement(...).createElementevidence scope-aware so shadowed imports, non-React imports, local helpers, and globalReact.createElementwithout an import do not count.oxlint-plugin-react-doctor.Before:
This could be reported as:
After:
This stays quiet because it has no direct React render output.
A real oversized component is still reported:
Test plan
Users can verify correctness with:
Note
Low Risk
Narrows an architecture lint heuristic and adds tests; no auth, data, or runtime product behavior changes.
Overview
no-giant-componentno longer warns on every oversized PascalCase function. It now requires direct React render evidence (JSX/fragments or scope-resolvedcreateElementfromreact/React.createElement) before reporting, so large service-style helpers stay quiet.Detection is scope-aware: nested inner components don’t count as outer render output; shadowed or non-React
createElement, locals, and unimported globalReactare ignored. The rule test harness synthesizeslocfrom parser offsets so line-threshold behavior is covered in unit tests, with adversarial pass/fail fixtures.Reviewed by Cursor Bugbot for commit b365c39. Bugbot is set up for automated code reviews on this repo. Configure here.