ngcompass 0.1.1-beta → 0.1.2-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,115 +1,102 @@
1
1
  <div align="center">
2
- <img src="./assets/logo-small.png" alt="ngcompass logo" width="120" />
3
2
  <h1>ngcompass</h1>
4
- <p><strong>Static analysis for Angular — catch architecture problems, performance issues, and code quality violations before they reach production.</strong></p>
5
-
3
+ <p><strong>Angular-aware static analysis for architecture, performance, SSR, security, and code quality.</strong></p>
6
4
  <p>
7
- <a href="https://www.npmjs.com/package/ngcompass"><img src="https://img.shields.io/npm/v/ngcompass/beta?label=beta&color=ec4899" alt="npm beta"></a>
8
- <img src="https://img.shields.io/badge/Angular-v15%2B-dd0031" alt="Angular v15+">
9
- <img src="https://img.shields.io/badge/Node.js-20%2B-339933" alt="Node.js 20+">
10
- <img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License">
5
+ <a href="https://www.npmjs.com/package/ngcompass"><img src="https://img.shields.io/npm/v/ngcompass/beta?label=beta&color=ec4899&style=flat-square" alt="npm beta"></a>
6
+ <img src="https://img.shields.io/badge/Angular-v15%2B-dd0031?style=flat-square" alt="Angular v15+">
7
+ <img src="https://img.shields.io/badge/Node.js-20%2B-339933?style=flat-square" alt="Node.js 20+">
8
+ <img src="https://img.shields.io/badge/license-MIT-6366f1?style=flat-square" alt="MIT License">
11
9
  </p>
12
10
  </div>
13
11
 
14
- ---
15
-
16
- ## What is ngcompass?
12
+ ## Overview
17
13
 
18
- ngcompass is a **command-line static analysis tool** built specifically for Angular projects. It scans your codebase without running it — reading your TypeScript, templates, and configuration files and reports issues across four key areas:
14
+ ngcompass is a command-line static analysis tool built for Angular projects. It reads TypeScript, Angular templates, styles, and project configuration without running the application, then reports issues that generic TypeScript linters often miss.
19
15
 
20
- | Category | What it checks |
21
- |---|---|
22
- | **Architecture** | Module boundaries, circular dependencies, improper component relationships |
23
- | **Performance** | Missing `OnPush`, untracked subscriptions, heavy template expressions |
24
- | **SSR Compatibility** | Browser-only APIs used in universal code, hydration pitfalls |
25
- | **Code Quality** | Deprecated APIs, naming conventions, dead code, missing best practices |
16
+ It is designed for teams that want a clearer view of Angular-specific risks: component architecture, rendering performance, SSR compatibility, Signals and RxJS patterns, template safety, and modern Angular API adoption.
26
17
 
27
- Think of it as **ESLint — but Angular-aware**. It understands the relationship between components, services, templates, and modules at a deeper level than generic TypeScript linters.
18
+ ## Highlights
28
19
 
29
- ---
20
+ | Area | What ngcompass helps find |
21
+ |---|---|
22
+ | Architecture | Circular dependencies, boundary violations, and fragile component relationships |
23
+ | Performance | Missing `OnPush`, expensive template expressions, missing `trackBy`, and inefficient bindings |
24
+ | SSR | Browser-only APIs in universal code, hydration risks, and render lifecycle pitfalls |
25
+ | Security | Unsafe template bindings and sanitizer bypasses |
26
+ | Reactivity | RxJS subscription issues, Signals misuse, and migration opportunities |
27
+ | Code quality | Deprecated patterns, focused tests, and modern Angular API improvements |
30
28
 
31
29
  ## Installation
32
30
 
31
+ Install the beta CLI globally:
32
+
33
33
  ```bash
34
- # npm
35
34
  npm install -g ngcompass@beta
35
+ ```
36
36
 
37
- # pnpm
38
- pnpm add -g ngcompass@beta
37
+ Or add it to a project:
38
+
39
+ ```bash
40
+ npm install --save-dev ngcompass@beta
39
41
  ```
40
42
 
41
- > This is a **beta release**. Install with `@beta` to opt in.
43
+ Using pnpm:
44
+
45
+ ```bash
46
+ pnpm add -D ngcompass@beta
47
+ ```
42
48
 
43
- ---
49
+ > ngcompass is currently in beta. Install with `@beta` to opt in to the prerelease channel.
44
50
 
45
51
  ## Quick Start
46
52
 
47
53
  ```bash
48
- # 1. Go to your Angular project
49
54
  cd my-angular-app
50
-
51
- # 2. Initialize configuration
52
55
  ngcompass init
53
-
54
- # 3. Run analysis
55
56
  ngcompass analyze
56
57
  ```
57
58
 
58
- That's it. ngcompass will scan your project and print a report to the terminal.
59
-
60
- For a visual report with search, filters, and per-file details, run:
59
+ Generate a self-contained visual report:
61
60
 
62
61
  ```bash
63
62
  ngcompass analyze --format ui
64
63
  ```
65
64
 
66
- ---
67
-
68
- ## Output Formats
69
-
70
- ngcompass can output results in multiple formats depending on your workflow:
65
+ Run through a project-local install:
71
66
 
72
67
  ```bash
73
- # Terminal output (default)
74
- ngcompass analyze
68
+ npx ngcompass analyze
69
+ pnpm exec ngcompass analyze
70
+ ```
75
71
 
76
- # Compact ESLint-style output (great for CI logs)
77
- ngcompass analyze --format console --compact
72
+ ## Output Formats
78
73
 
79
- # HTML report written to a file (default: ngcompass-report.html)
80
- ngcompass analyze --format html
81
- ngcompass analyze --format html --output my-report.html
74
+ | Command | Output |
75
+ |---|---|
76
+ | `ngcompass analyze` | Default terminal report |
77
+ | `ngcompass analyze --format console --compact` | Compact one-line issue output |
78
+ | `ngcompass analyze --format html --output report.html` | Self-contained HTML report |
79
+ | `ngcompass analyze --format ui` | Interactive HTML report alias |
80
+ | `ngcompass analyze --format json > results.json` | Machine-readable JSON |
81
+ | `ngcompass analyze --format sarif > results.sarif` | SARIF for GitHub Code Scanning |
82
82
 
83
- # Interactive UI report (alias for html — same output)
84
- ngcompass analyze --format ui
83
+ ## Configuration
85
84
 
86
- # Machine-readable JSON
87
- ngcompass analyze --format json > results.json
85
+ Create a configuration file:
88
86
 
89
- # SARIF for GitHub Code Scanning
90
- ngcompass analyze --format sarif > results.sarif
87
+ ```bash
88
+ ngcompass init
91
89
  ```
92
90
 
93
- The HTML/UI report gives you a full visual breakdown — severity charts, per-file drill-down, search and filter — all in a single self-contained file.
94
-
95
- ---
96
-
97
- ## Configuration
98
-
99
- Run `ngcompass init` to generate `ngcompass.config.ts` in your project root:
91
+ This generates `ngcompass.config.ts`:
100
92
 
101
93
  ```ts
102
94
  import { defineConfig } from '@ngcompass/config';
103
95
 
104
96
  export default defineConfig({
105
- // Start from a preset: 'ngcompass:recommended' | 'ngcompass:strict' | 'ngcompass:performance' | 'ngcompass:reactivity' | 'ngcompass:all'
106
97
  extends: 'ngcompass:recommended',
107
98
 
108
- // Files to scan
109
- include: [
110
- 'src/**/*.ts',
111
- 'src/**/*.html',
112
- ],
99
+ include: ['src/**/*.ts', 'src/**/*.html'],
113
100
 
114
101
  exclude: [
115
102
  'node_modules/**',
@@ -121,179 +108,137 @@ export default defineConfig({
121
108
  '**/*.test.ts',
122
109
  ],
123
110
 
124
- // Override individual rules
125
- rules: {
126
- 'prefer-on-push-component-change-detection': 'error',
127
- 'no-document-access': 'warn',
111
+ profiles: {
112
+ ci: {
113
+ outputFormat: 'json',
114
+ maxWarnings: 0,
115
+ },
128
116
  },
129
117
  });
130
118
  ```
131
119
 
132
120
  ### Presets
133
121
 
134
- | Preset | Description |
122
+ | Preset | Purpose |
135
123
  |---|---|
136
- | `ngcompass:recommended` | Balanced set of rules for most Angular projects |
137
- | `ngcompass:strict` | Stricter checks including all recommended rules |
138
- | `ngcompass:performance` | Focus on rendering performance and change detection |
139
- | `ngcompass:reactivity` | Signals correctness and RxJS-to-Signals migration rules |
140
- | `ngcompass:all` | Every built-in rule enabled at its default severity |
141
-
142
- ### Supported Rules
124
+ | `ngcompass:recommended` | Balanced default for most Angular projects |
125
+ | `ngcompass:strict` | Stronger enforcement for mature codebases |
126
+ | `ngcompass:performance` | Rendering and change-detection checks |
127
+ | `ngcompass:reactivity` | Signals and RxJS correctness |
128
+ | `ngcompass:security` | Security-focused Angular checks |
129
+ | `ngcompass:ssr` | Server rendering and hydration safety |
130
+ | `ngcompass:all` | Every built-in rule at its default severity |
143
131
 
144
- Run `ngcompass rules` to inspect the same list from the CLI.
145
-
146
- | Category | Rules |
147
- |---|---|
148
- | Correctness | `component-no-manual-detect-changes`, `signal-no-side-effects-in-computed`, `signal-effect-must-be-destroy-scoped`, `rxjs-no-nested-subscribe` |
149
- | Performance | `prefer-on-push-component-change-detection`, `template-no-call-expression`, `template-trackby-required`, `template-no-object-literal-binding`, `template-no-array-literal-binding` |
150
- | Security | `no-bypass-sanitization`, `template-no-unsafe-bindings` |
151
- | SSR | `no-document-access`, `prefer-after-render-over-after-view-init` |
152
- | Reactivity | `rxjs-no-subscribe-in-component`, `rxjs-require-takeUntilDestroyed`, `rxjs-avoid-subject-as-event-bus`, `rxjs-prefer-toSignal-for-template-state`, `toSignal-require-initialValue`, `signal-prefer-computed-over-sync-effect`, `signal-avoid-untracked-overuse` |
153
- | Modern API | `prefer-inject-over-constructor-di`, `signal-prefer-input-signal`, `signal-prefer-output-function`, `signal-prefer-model` |
154
- | Template | `template-prefer-control-flow`, `template-no-async-pipe-duplication` |
155
- | Testing | `spec-no-focused-test` |
132
+ Override individual rules in the same config:
156
133
 
157
- ---
134
+ ```ts
135
+ export default defineConfig({
136
+ extends: ['ngcompass:recommended', 'ngcompass:performance'],
137
+ rules: {
138
+ 'prefer-on-push-component-change-detection': 'error',
139
+ 'no-document-access': 'warn',
140
+ },
141
+ });
142
+ ```
158
143
 
159
144
  ## Commands
160
145
 
161
146
  | Command | Description |
162
147
  |---|---|
163
- | `ngcompass init` | Generate a `ngcompass.config.ts` in the current directory |
164
- | `ngcompass analyze` | Run analysis on the project |
165
- | `ngcompass config health` | Validate the current configuration |
166
- | `ngcompass rules` | List all available rules |
167
- | `ngcompass rules <name>` | Inspect a specific rule |
168
- | `ngcompass cache info` | Show cache status and statistics |
169
- | `ngcompass cache clear` | Clear the analysis cache |
170
- | `ngcompass cache path` | Show the cache directory location |
171
-
172
- ### Global Options
173
-
174
- | Option | Description |
175
- |---|---|
176
- | `--debug` | Enable detailed debug logs across all modules |
177
- | `-V, --version` | Display the ngcompass version |
148
+ | `ngcompass init` | Create `ngcompass.config.ts` |
149
+ | `ngcompass analyze` | Run analysis |
150
+ | `ngcompass rules` | List available rules |
151
+ | `ngcompass rules <name>` | Inspect one rule |
152
+ | `ngcompass config health` | Validate configuration |
153
+ | `ngcompass cache info` | Show cache status |
154
+ | `ngcompass cache clear` | Clear cached analysis data |
155
+ | `ngcompass cache path` | Print the cache directory |
178
156
 
179
157
  ### Analyze Options
180
158
 
181
159
  | Option | Description |
182
160
  |---|---|
183
- | `--format <fmt>` | Output format: `console`, `json`, `sarif`, `html`, `ui` |
184
- | `--output <path>` | Output path for HTML/UI reports (default: `ngcompass-report.html`) |
185
- | `--compact` | ESLint-style compact one-line-per-issue output |
186
- | `-q, --quiet` | Show summary counts only; suppress violation details |
187
- | `--no-recommendation` | Suppress fix recommendations from output |
188
- | `--rule <id>` | Run a single rule in isolation |
189
- | `--force` | Skip cache and re-run full analysis |
190
- | `--profile <name>` | Use a named profile from your config |
191
- | `--max-workers <n>` | Cap the number of worker threads (e.g. `--max-workers 2`) |
192
- | `--type-aware-chunk-size <n>` | Files per type-aware chunk (default `400`; lower = less peak memory) |
193
- | `--skip-type-check` | Skip rules that require the TypeScript type checker |
194
-
195
- ### Init Options
196
-
197
- | Option | Description |
198
- |---|---|
199
- | `-f, --force` | Overwrite an existing configuration file |
200
- | `--cwd <path>` | Project directory where the configuration will be created |
201
-
202
- ### Rules Options
203
-
204
- | Option | Description |
205
- |---|---|
206
- | `--preset <name>` | Filter rules by preset: `recommended`, `strict`, `performance`, `reactivity`, or `all` |
207
-
208
- ### Cache Options
209
-
210
- All `cache` subcommands accept `-p, --profile <name>` to resolve cache settings from a named config profile.
211
-
212
- #### `cache clear`
213
-
214
- | Option | Description |
215
- |---|---|
216
- | `--type <type>` | Cache type to clear: `ast`, `config`, `results`, or `all` (default: `all`) |
217
- | `-p, --profile <name>` | Configuration profile used to resolve cache settings |
218
-
219
- #### `cache info` / `cache path`
220
-
221
- | Option | Description |
222
- |---|---|
223
- | `-p, --profile <name>` | Configuration profile used to resolve cache settings |
224
-
225
- ### Config Health Options
226
-
227
- | Option | Description |
228
- |---|---|
229
- | `-p, --profile <name>` | Configuration profile to validate |
230
-
231
- ---
232
-
233
- ## CI Integration
234
-
235
- ngcompass exits with code `0` on success and non-zero when violations are found. Drop it into any CI pipeline:
161
+ | `--format <fmt>` | `console`, `json`, `sarif`, `html`, or `ui` |
162
+ | `--output <path>` | Output path for HTML/UI reports |
163
+ | `--compact` | Use compact issue output |
164
+ | `-q, --quiet` | Show summary counts only |
165
+ | `--no-recommendation` | Hide fix recommendations |
166
+ | `--rule <id>` | Run one rule in isolation |
167
+ | `--force` | Ignore cached results |
168
+ | `-p, --profile <name>` | Run a named config profile |
169
+ | `--max-workers <n>` | Limit worker threads |
170
+ | `--type-aware-chunk-size <n>` | Tune type-aware batch size |
171
+ | `--skip-type-check` | Skip rules that require TypeScript type checking |
172
+
173
+ ## CI
174
+
175
+ ngcompass exits with code `0` when analysis passes and a non-zero code when configured violations are found.
236
176
 
237
177
  ```yaml
238
- # GitHub Actions example
239
178
  - name: Run ngcompass
240
179
  run: ngcompass analyze --format sarif > results.sarif
241
180
 
242
- - name: Upload to Code Scanning
181
+ - name: Upload SARIF
243
182
  uses: github/codeql-action/upload-sarif@v3
244
183
  with:
245
184
  sarif_file: results.sarif
246
185
  ```
247
186
 
248
- ---
249
-
250
187
  ## Caching
251
188
 
252
- ngcompass caches analysis results between runs. Only changed files are re-analyzed, making subsequent runs significantly faster on large codebases.
189
+ ngcompass caches file discovery, execution plans, AST work, rule results, and full analysis output. Warm runs can reuse unchanged work instead of parsing and analyzing the entire project again.
253
190
 
254
191
  ```bash
255
- ngcompass cache info # see what's cached
256
- ngcompass cache clear # reset the cache
257
- ngcompass analyze --force # skip cache for this run
192
+ ngcompass cache info
193
+ ngcompass cache clear
194
+ ngcompass analyze --force
258
195
  ```
259
196
 
260
- ---
261
-
262
- ## Packages
263
-
264
- ngcompass is a monorepo. The CLI is published as `ngcompass`; internal libraries use the `@ngcompass` scope:
197
+ ## Monorepo
265
198
 
266
- | Package | Description |
199
+ | Package | Responsibility |
267
200
  |---|---|
268
- | [`ngcompass`](packages/cli) | The CLI tool this is what you install |
269
- | [`@ngcompass/engine`](packages/engine) | Rule execution engine |
270
- | [`@ngcompass/rules`](packages/rules) | Built-in rule collection |
271
- | [`@ngcompass/ast`](packages/ast) | AST parsers and visitors |
272
- | [`@ngcompass/scanner`](packages/scanner) | File system scanning |
273
- | [`@ngcompass/planner`](packages/planner) | Incremental execution planner |
274
- | [`@ngcompass/cache`](packages/cache) | Caching layer |
275
- | [`@ngcompass/reporters`](packages/reporters) | Output formatters (console, JSON, SARIF, HTML) |
276
- | [`@ngcompass/config`](packages/config) | Config loading and validation |
201
+ | [`ngcompass`](packages/cli) | CLI entry point |
202
+ | [`@ngcompass/config`](packages/config) | Config loading, validation, profiles, and health checks |
203
+ | [`@ngcompass/scanner`](packages/scanner) | File discovery and filtering |
204
+ | [`@ngcompass/rules`](packages/rules) | Built-in rules, presets, and rule registry |
205
+ | [`@ngcompass/planner`](packages/planner) | Incremental execution planning |
206
+ | [`@ngcompass/engine`](packages/engine) | Rule execution and analysis orchestration |
207
+ | [`@ngcompass/ast`](packages/ast) | TypeScript, template, and style parsing helpers |
208
+ | [`@ngcompass/cache`](packages/cache) | Memory and disk cache services |
209
+ | [`@ngcompass/reporters`](packages/reporters) | Console, JSON, SARIF, and HTML reporters |
277
210
  | [`@ngcompass/common`](packages/common) | Shared types and utilities |
211
+ | [`@ngcompass/site`](packages/site) | Documentation site |
278
212
 
279
- ---
213
+ ## Development
280
214
 
281
- ## Requirements
215
+ ```bash
216
+ pnpm install
217
+ pnpm build
218
+ pnpm test
219
+ pnpm typecheck
220
+ ```
282
221
 
283
- - **Node.js** `^20.19.0` or `>=22.12.0`
284
- - **Angular** v15 or later
222
+ Additional workspace checks:
285
223
 
286
- ---
224
+ ```bash
225
+ pnpm smoke
226
+ pnpm validate:packages
227
+ pnpm prerelease:check
228
+ ```
229
+
230
+ ## Requirements
287
231
 
288
- ## Known Limitations (Beta)
232
+ - Node.js `^20.19.0` or `>=22.12.0`
233
+ - Angular v15 or later
234
+ - pnpm for repository development
289
235
 
290
- - Rule names, messages, and report layout may change before `1.0`
291
- - Template parsing is best-effort — highly dynamic templates may not be fully understood
292
- - SARIF output targets code scanning ingestion and may omit some visual details
293
- - Validate against your project before enforcing ngcompass as a required CI gate
236
+ ## Beta Notes
294
237
 
295
- ---
238
+ - Rule names, messages, and report layout may change before `1.0`.
239
+ - Template analysis is best-effort for highly dynamic templates.
240
+ - Validate ngcompass against your project before making it a required CI gate.
296
241
 
297
242
  ## License
298
243
 
299
- MIT see [LICENSE](./LICENSE)
244
+ MIT. See [LICENSE](./LICENSE).