Skip to content

prop-flow: make output batch-safe for a loop over changed files - #937

Merged
fxOne merged 2 commits into
masterfrom
prop-flow-batch-safe-output
Aug 3, 2026
Merged

prop-flow: make output batch-safe for a loop over changed files#937
fxOne merged 2 commits into
masterfrom
prop-flow-batch-safe-output

Conversation

@fxOne

@fxOne fxOne commented Aug 3, 2026

Copy link
Copy Markdown
Owner

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 --json stays 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

  • A file with no exported component is no longer an error. analyseProps returns an empty report and the CLI exits 0. Exit 2 is now reserved for what actually blocked the analysis: a missing file, no resolvable compiler config, or a tsconfig that does not span the file.
  • Report gains a required components field — 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.
  • Under --json a 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 exit 1 with no file) deliberately stays plain text.
  • An exported useX taking 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 back unused-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.
  • Text output keeps its tsconfig and Program file-count header on an empty report, and says "no exported component" where that is the reason rather than "no props to report".
  • formatJsonError is exported from the package index; resolveTarget is extracted out of analyseProps to separate target resolution from the prop walk.
  • README documents the batching workflow and the exit-code contract; CHANGELOG and version updated for 3.0.0.

@fxOne
fxOne merged commit b2173dd into master Aug 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant