A walkthrough of building a custom CLI tool called rxjs-operator-counter using TSLint's programmatic API and AST traversal. The author creates a custom TSLint rule and walker to iterate TypeScript files, detect RxJS operators used inside pipe() calls, count their occurrences, and print a summary. The post covers extending AbstractRule, using visitIdentifier, running TSLint as a library, writing fixture-based tests, and refactoring the AST traversal using TSQuery's CSS-like selector syntax.
Table of contents
Iterating files inside a projectSearching for RxJS operatorsKeeping count of the operators and logging the resultsLinting the whole workspaceThe resultTestingRefactoring with TSQueryConclusion1 Impression