-
Notifications
You must be signed in to change notification settings - Fork 397
feat(react-doctor): typed errors + config rootDir for diagnose() targeting #200
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
02086d7
feat(react-doctor): add typed error classes to node api
cursoragent 67c4b32
feat(react-doctor): refuse ambiguous diagnose() targets via Ambiguous…
cursoragent 45a3ef0
feat(react-doctor): allow setting rootDir in react-doctor.config.json
cursoragent 71a5ec8
chore: drop changesets for this branch
cursoragent 3568c8c
test(react-doctor): use Array.toSorted() in ambiguous-project assertion
cursoragent af22448
fix(react-doctor): pass configOverride from CLI main scan loop
cursoragent 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { buildNoReactDependencyError } from "./constants.js"; | ||
|
|
||
| export class ReactDoctorError extends Error { | ||
| override readonly name: string = "ReactDoctorError"; | ||
|
|
||
| constructor(message: string, options?: ErrorOptions) { | ||
| super(message, options); | ||
| Object.setPrototypeOf(this, new.target.prototype); | ||
| } | ||
| } | ||
|
|
||
| export class ProjectNotFoundError extends ReactDoctorError { | ||
| override readonly name = "ProjectNotFoundError"; | ||
| readonly directory: string; | ||
|
|
||
| constructor(directory: string, options?: ErrorOptions) { | ||
| super( | ||
| `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, | ||
| options, | ||
| ); | ||
| this.directory = directory; | ||
| } | ||
| } | ||
|
|
||
| export class NoReactDependencyError extends ReactDoctorError { | ||
| override readonly name = "NoReactDependencyError"; | ||
| readonly directory: string; | ||
|
|
||
| constructor(directory: string, options?: ErrorOptions) { | ||
| super(buildNoReactDependencyError(directory), options); | ||
| this.directory = directory; | ||
| } | ||
| } | ||
|
|
||
| export class PackageJsonNotFoundError extends ReactDoctorError { | ||
| override readonly name = "PackageJsonNotFoundError"; | ||
| readonly directory: string; | ||
|
|
||
| constructor(directory: string, options?: ErrorOptions) { | ||
| super(`No package.json found in ${directory}`, options); | ||
| this.directory = directory; | ||
| } | ||
| } | ||
|
|
||
| export class AmbiguousProjectError extends ReactDoctorError { | ||
| override readonly name = "AmbiguousProjectError"; | ||
| readonly directory: string; | ||
| readonly candidates: readonly string[]; | ||
|
|
||
| constructor(directory: string, candidates: readonly string[], options?: ErrorOptions) { | ||
| super( | ||
| `Multiple React projects found under ${directory} (${candidates.length} candidates): ${candidates.join(", ")}. Re-run diagnose() with one of those subdirectories, or iterate them yourself.`, | ||
| options, | ||
| ); | ||
| this.directory = directory; | ||
| this.candidates = candidates; | ||
| } | ||
| } | ||
|
|
||
| export const isReactDoctorError = (value: unknown): value is ReactDoctorError => | ||
| value instanceof ReactDoctorError; |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.