Repository navigation
Require React Doctor 100 in local verification #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ParthJadhav
wants to merge
1
commit into
main
Choose a base branch
from
codex/react-doctor-100
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/env node | ||
| import { spawnSync } from "node:child_process"; | ||
| import { mkdirSync, writeFileSync } from "node:fs"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const root = fileURLToPath(new URL("../", import.meta.url)); | ||
| const result = spawnSync( | ||
| "npx", | ||
| ["--yes", "react-doctor@latest", ".", "--yes", "--scope", "full", "--json"], | ||
| { | ||
| cwd: root, | ||
| encoding: "utf8", | ||
| maxBuffer: 32 * 1024 * 1024, | ||
| }, | ||
| ); | ||
| if (result.error || !result.stdout?.trim()) { | ||
| console.error(result.error?.message ?? result.stderr ?? "React Doctor returned no report."); | ||
| process.exit(1); | ||
| } | ||
| let report; | ||
| try { | ||
| report = JSON.parse(result.stdout); | ||
| } catch { | ||
| console.error("React Doctor returned an invalid report:", result.stdout, result.stderr); | ||
| process.exit(1); | ||
| } | ||
| const output = new URL("../node_modules/.cache/react-doctor/", import.meta.url); | ||
| mkdirSync(output, { recursive: true }); | ||
| writeFileSync(new URL("report.json", output), JSON.stringify(report, null, 2) + "\n"); | ||
| for (const finding of report.diagnostics ?? []) { | ||
| console.log( | ||
| `${finding.filePath}:${finding.line} ${finding.severity} ${finding.plugin}/${finding.rule}: ${finding.message}`, | ||
| ); | ||
| } | ||
| const projects = report.projects ?? []; | ||
| const complete = | ||
| report.ok === true && | ||
| report.mode === "full" && | ||
| report.reactDetected === true && | ||
| projects.length > 0 && | ||
| projects.every( | ||
| (project) => | ||
| project.complete === true && | ||
| project.analyzedFileCount > 0 && | ||
| project.skippedChecks?.length === 0, | ||
| ); | ||
| const perfect = | ||
| report.summary?.score === 100 && projects.every((project) => project.score?.score === 100); | ||
| console.log( | ||
| `React Doctor ${report.version ?? ""}: ${report.summary?.score ?? "unavailable"}/100 (required: 100).`, | ||
| ); | ||
| console.log("Report: node_modules/.cache/react-doctor/report.json"); | ||
| if (!complete) | ||
| console.error( | ||
| "React Doctor did not complete every check; retry when the scanner and its services are available.", | ||
| ); | ||
| if (!perfect) console.error("Fix the findings and rerun the full scan to reach 100."); | ||
| process.exit(result.status === 0 && complete && perfect ? 0 : 1); | ||
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin
react-doctorto a reviewed, lockfile-controlled version instead of executing@latest. The publish path runsbun run release, which invokesbun run checkand this script from the privileged Changesets step in.github/workflows/release.yml; that step exposes a write-capableGITHUB_TOKENand hasid-token: write. A compromised or newly malicious registry release could therefore execute arbitrary code with release credentials, while even a benign incompatible update can unexpectedly block publishing.Useful? React with 👍 / 👎.