@jsverse/letify
v1.0.0
Published
<div align="center"> <img width="300px" src="./logo-gradient.svg" alt="Letify Logo"> </div>
Readme
Letify CLI helps Angular developers optimize their templates by scanning your files and detecting multiple async subscriptions to the same stream.
Usage
To get started, install Letify CLI:
npm i -D @jsverse/letifyThen, run the command:
npx letify [analyze|fix] 'a/b.html' 'c/**/*.html' ...analyze: Identifies duplicate subscriptions in the specified files and generates a report.fix: Identifies duplicate subscriptions and replace duplications with a single@letdeclaration at the beginning of the template.
CI / Lint-
Letify will return an error exit code if any duplicate subscriptions are detected in the specified files. It can be seamlessly integrated into your lint-staged or CI workflows to prevent duplicate subscriptions from being committed.
Usage notes
- Letify ignores commented code and does not analyze it.
- Keyed reads (
data[prop] | async) and function calls with arguments (myMethod(value, ...) | async) are currently not supported. - You'll need Angular
>=18.1to use the@letsyntax, if you are using an older version, run theanalyzecommand and use alternatives to reuse your subscriptions.
Options
-r, --reporter <type>: Specifies the report format:html(default): Generates an HTML report.list: Outputs a simple list of suggestions.json: Provides a JSON report for programmatic use.
-o, --open: Automatically opens the HTML report once generated (defaulttrue.--verify-convention(default:false): Checks that stream names (observables) in the templates follow the convention of ending with a$sign.--variable-suffix(default:value): Adds a suffix to the declared variable infixmode, mainly to avoid collisions.
Debugging
You can extend the default logs by setting the DEBUG environment variable:
DEBUG=letify:* npx letify ...Supported namespaces: letify:*|letify:fix.
