Open source · Design Systems

Component Prop Contract

Compare component inputs and events with the public API contract.

v0.1.0 · Node.js 22+ · MIT

Browse the public repository · View releases

A contract goes in: a version, and for each component the source file, the exported props type, and the members that type is required to carry. The TypeScript sources it names go in with it.

This walkthrough uses the tool's public README and checked-in example files. Run the command from a repository checkout with Node.js 22+; inspect the source before using it on your own files.

Run the checked-in example

node bin/component-prop-contract.mjs --root examples/honoured
# exit 0 -- the surface matches the contract; two private members excluded

node bin/component-prop-contract.mjs --root examples/broken
# exit 1 -- a renamed union member, an optional prop made required,
#           a prop dropped, and one compatible addition

node bin/component-prop-contract.mjs --root examples/unsupported
# exit 2 -- an "extends" clause, so the surface was never established
#           and NOTHING is reported as missing from it

Read the result

file and pointer name two different documents, on purpose. location.file is the TypeScript source the observation is about; location.pointer is always a JSON Pointer into the contract, naming the field that states the requirement. A source has no field path worth pointing at and the contract has no line worth reading, so each finding carries the useful half of both. A test resolves every emitted pointer against the contract document, so a consumer can rely on it. The human summary on stderr prints them with <- contract between them, because concatenated they read as a filesystem path and are not one.

Where this check stops

Every limit is enforced and tested. An unknown limit key throws rather than being ignored, and a flag that carries a value may be given once: a repeated flag is a configuration error, not a silent last-wins.

Before adapting the command to your own workflow, review the accepted inputs, exit codes and safety boundaries in the README.

Compiled with AI assistance from checked-in public documentation and example scripts. Run the example and review the repository's current documentation before relying on its result.