💡 Deep Analysis
4
What kinds of projects or teams are best suited for react-doctor, and in which scenarios is it not recommended?
Core Analysis¶
Core Issue: Adoption should be driven by tech stack, repo scale, and the need for static quality metrics.
Suitable Scenarios (Recommended)¶
- Medium-to-large React apps: Complex state/effect logic, multi-team collaboration, and PR workflows benefit from anti-pattern detection.
- Cross-platform projects: React Native + Web codebases gain from framework-aware rules to reduce cross-platform false positives.
- Teams wanting measurable health: Those wanting a 0–100 health metric in CI/PR to track code quality over time.
- Teams using/training coding agents:
npx react-doctor installcan embed best practices into code-generation agents.
Not Recommended (Avoid)¶
- Non-React projects: The rule set is React-focused and offers little value for Vue/Angular/back-end repos.
- Small or disposable repos: Maintenance and config cost may outweigh benefits.
- Restricted runtime environments: Repos that cannot run Node or install dependencies will struggle to integrate.
Practical Advice¶
- Run
npx -y react-doctor@latest .as a trial to inspect score and top rule violations. - Consider whether your team can maintain ignore lists and config—mid/large teams gain more.
Important: If your main issues are runtime-only, supplement static checks with tests and runtime monitoring.
Summary: Best for large React codebases needing semantic governance; not suitable as a primary tool in non-React or constrained environments.
How to smoothly introduce react-doctor into existing CI/ESLint workflows while avoiding noise (false positives and third-party code)?
Core Analysis¶
Core Issue: The biggest friction when adding a new static checker is noise from vendor/generated files and improper suppressions.
Technical Analysis¶
- Key capabilities:
react-doctor.config.jsonsupportsignore.rules,ignore.files, andignore.overridesfor fine-grained control.- The tool respects
.gitignore,.eslintignore,.oxlintignoreand can merge existing lint configs (adoptExistingLintConfig). - GitHub Action integration can post PR comments and expose scores for visibility rather than immediate failure.
Practical Recommendations (phased rollout)¶
- Merge existing config: Enable
adoptExistingLintConfig:trueso react-doctor folds in current ESLint rules and avoids duplicate alerts. - Exclude vendor/generated files: Add
src/generated/**,node_modules/**or build output toignore.files; useignore.overridesfor file-specific exceptions. - Show, don’t block: Configure the Action to post comments (warnings) on PRs first, then escalate to
fail-onprogressively. - Use incremental scans: Use
--diff/--stagedfor large repos to limit CI time and focus on changed files. - Debug suppressions: Run
--explainwhen suppression annotations seem ineffective to correct annotation placement.
Important: Don’t flip all strict rules on in a large repo at once—converge gradually.
Summary: Merge lint configs, use fine-grained ignores, make PR feedback non-blocking initially, and use incremental scans to integrate react-doctor with minimal noise.
How reliable is the tool for dead-code and unused-symbol detection? What common false positives occur and how to reduce them?
Core Analysis¶
Core Issue: Dead-code detection relies on static reachability analysis and has inherent blind spots with modern build and dynamic loading patterns.
Technical Analysis¶
- Accurate cases:
- Explicitly unused functions/variables/components not imported anywhere.
- Modules whose static reference graph is fully resolvable.
- Common false positives:
- Dynamic imports / code-splitting: Imports computed from strings or runtime values are not statically resolvable.
- Runtime registration/reflection: Frameworks/plugins registering components at runtime via conventions/metadata.
- Dependency injection or service locators: Symbols injected or referenced via reflection at runtime.
- Test/tooling references: Test runners or build tools referencing files only at runtime.
How to reduce false positives¶
- Configure ignores: Add generated or runtime-registered directories to
ignore.files(e.g.,src/generated/**,plugins/**). - Explicit exports/annotations: Mark modules referenced at runtime with explicit exports or comments to aid static tooling or to be excluded.
- Use overrides: Use
ignore.overridesto allow specific files exceptions while keeping other rules active. - Prioritize diffs: Focus human review on changed files (
--diff/--staged) to reduce noisy audits.
Important: Treat static dead-code detection as high-value but imperfect—great for explicit unused code, needing config for dynamic runtime patterns.
Summary: Reliable for most static cases; mitigate false positives in dynamic-loading or runtime-registration scenarios via config, annotations, and diff-first workflows.
How can react-doctor be integrated with code-generating coding agents to reduce the likelihood of agents producing bad React code?
Core Analysis¶
Core Issue: Injecting static rules and explainability into coding agents enables prevention at generation time and creates a feedback loop for continuous improvement.
Technical Analysis¶
- Built-in capability:
npx react-doctor installcan inject rules/guidance into many agents; the tool runs via CLI/Action/ESLint plugin and offers--explainto clarify rule triggers. - Integration paths:
- Pre-generation: Seed agents’ prompts/templates with recommended rules, anti-pattern examples, and do/don’t lists.
- Post-generation: Run react-doctor immediately on generated output and feed diagnostics back to the agent to request fixes.
- CI gatekeeping: Use diff scans on agent PRs and post scores/comments as a quality gate or visibility metric.
Practical Recommendations¶
- Add concise rule summaries to agent prompts (e.g., avoid side effects during render; prefer
useMemo/useCallbackonly when needed). - Include
react-doctor installin agent initialization so team rules are automatically applied. - Implement a post-generation hook to run react-doctor and return
--explaindetails to the agent for correction. - Use
--diffmode for agent-generated changes to minimize scan overhead.
Important: Agents must be able to receive injected rules and a feedback loop; otherwise you can only audit post-generation, not prevent errors at source.
Summary: A combined strategy—pre-populating prompts, automatic post-generation scans with feedback, and CI scoring—meaningfully reduces bad React code from agents and helps bake best practices into the generation pipeline.
✨ Highlights
-
Generates a 0–100 project health score in one command
-
Works with Next.js, Vite, and React Native
-
Built-in GitHub Actions and CLI integration
-
Missing license declaration and formal releases
-
Repository metadata shows missing contributors and commits
🔧 Engineering
-
Rule-based static diagnostics covering state & effects, performance, and accessibility
-
Posts findings to PRs and outputs a reusable health score for automation
-
Supports configurable ignores, merging with existing ESLint, and optional plugins
⚠️ Risks
-
No clear license declared; may block enterprise or restricted-environment adoption
-
Metadata shows few contributors, no releases and no recent commits in provided data, indicating maintenance and long‑term support risk
-
Rules depend on project environment and ESLint plugins, so false positives or coverage gaps are possible
👥 For who?
-
Intended for React developers, code reviewers, and quality teams
-
Suitable for CI integration, automated PR comments, and local code health checks
-
Can feed best-practice guidance to coding agents to reduce low-quality code generation