prop-flow: make output batch-safe for a loop over changed files - #937
Merged
Conversation
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.
Summary
Makes prop-flow safe to run in a loop over changed files. A file with nothing to analyse is now a success rather than a failure, a handled failure under
--jsonstays inside the JSON stream, and hooks are no longer mistaken for components. All three change the observable contract, so the package goes to 3.0.0.Changes
analysePropsreturns an empty report and the CLI exits0. Exit2is now reserved for what actually blocked the analysis: a missing file, no resolvable compiler config, or a tsconfig that does not span the file.Reportgains a requiredcomponentsfield — the number of exported components with a typed props object. It is what tells the two empty reports apart: no component to look at (0) versus a component whose props are all required.--jsona handled failure is written to stdout as{"error": …}instead of to stderr, so an invocation that names a file emits exactly one JSON object whatever happens and a failing file no longer breaks the parse for the rest of the batch. The flag is read off the raw argv so a bad argument reaches the envelope too. Usage output (--help, and exit1with no file) deliberately stays plain text.useXtaking an options object is dropped from component discovery. It is indistinguishable from a component to the AST and has no JSX call sites, so every one of its options came backunused-component— a statement about the walk, not about the hook. Only discovery is narrowed; a prop passing through a hook is still traced and still reported at the component that declares it.formatJsonErroris exported from the package index;resolveTargetis extracted out ofanalysePropsto separate target resolution from the prop walk.