Skip to content

Commit d10511f

Browse files
committed
docs: explain automatic rule caching differentiation
1 parent 5c314b3 commit d10511f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ export default defineRule(({ typescript: ts, file, report }) => {
105105
});
106106
```
107107

108+
## Rule Caching Mechanism
109+
110+
TSSLint's high performance is partly due to its intelligent caching strategy, which automatically distinguishes between **Syntax-Aware** and **Type-Aware** rules.
111+
112+
By default, all rule diagnostics are cached. However, the cache is automatically disabled for a rule in two specific scenarios:
113+
114+
1. **Type-Aware Detection**: If a rule accesses the type-checking context via `RuleContext.program` (e.g., to check types, inheritance, or signatures), TSSLint automatically detects it as a Type-Aware rule. Since type information can change globally, the cache for this rule is automatically managed and potentially invalidated to ensure accuracy.
115+
2. **Manual Exclusion**: A rule can explicitly prevent a specific diagnostic from being cached by calling `report().withoutCache()`. This is useful for diagnostics that rely on external factors (like file system checks or network status) that TSSLint cannot track.
116+
117+
This automatic differentiation allows TSSLint to maximize performance for simple syntax rules while maintaining correctness for complex type-aware rules.
118+
108119
## CLI Usage
109120

110121
The `@tsslint/cli` package provides a command-line tool for CI/CD and build processes.

0 commit comments

Comments
 (0)