redocly-cli
redocly-cli copied to clipboard
Remove unused components transitively
What/Why/How?
Removes components if their parent paths were removed. Loops until no more changes were made.
Reference
Fixes https://github.com/Redocly/redocly-cli/issues/874
Testing
Couldn't run tests in a GitHub Codespace, so opening a draft here for CI.
Check yourself
- [ ] Code changed? - Tested with redoc/reference-docs/workflows (internal)
- [ ] All new/updated code is covered with tests
- [ ] New package installed? - Tested in different environments (browser/node)
Security
- [ ] Security impact of change has been considered
- [ ] Code follows company security practices and guidelines
🦋 Changeset detected
Latest commit: def381eb2db9c1250148c008608766b8d4f00410
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 2 packages
Name | Type |
---|---|
@redocly/openapi-core | Patch |
@redocly/cli | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@tatomyr Please have a look! Tests are green, please let me know if anything else needs to happen to get this over the finish line.
@fb55 sure thing, will take a look!
Thanks for the review, addressed all comments!
And one more thing. Whatever changes here should also apply to the corresponding rule no-unused-components.
Do you mean introducing the additional data structures for tracking where a component is used?
Do you mean introducing the additional data structures for tracking where a component is used?
Actually, at a second glance, I'm not sure we should apply the same logic in the rule itself... We're not removing transitive components but rather checking the current state.
Let me have another look.
WIth the latest changes it doesn't seem to remove transitive references anymore 😅
Tests are passing, and the codebase I am looking at (~1000 auto-generated components with ~20% unused) is not showing any unused component errors after processing. But the reported number of removed components has gone down from ~220 to ~160 — not quite sure about what happened here.
Tests are passing
Indeed they are. Sorry, mixed up with different errors 🙂.
@tatomyr Anything I can help with to make this move forward?
Realised there was a comment I had not addressed, just did so!
@tatomyr Thanks for shepherding this to the finish line!