ngcompass 0.1.1-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ngcompass
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,299 @@
1
+ <div align="center">
2
+ <img src="./assets/logo-small.png" alt="ngcompass logo" width="120" />
3
+ <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
+
6
+ <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">
11
+ </p>
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## What is ngcompass?
17
+
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:
19
+
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 |
26
+
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.
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ # npm
35
+ npm install -g ngcompass@beta
36
+
37
+ # pnpm
38
+ pnpm add -g ngcompass@beta
39
+ ```
40
+
41
+ > This is a **beta release**. Install with `@beta` to opt in.
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ```bash
48
+ # 1. Go to your Angular project
49
+ cd my-angular-app
50
+
51
+ # 2. Initialize configuration
52
+ ngcompass init
53
+
54
+ # 3. Run analysis
55
+ ngcompass analyze
56
+ ```
57
+
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:
61
+
62
+ ```bash
63
+ ngcompass analyze --format ui
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Output Formats
69
+
70
+ ngcompass can output results in multiple formats depending on your workflow:
71
+
72
+ ```bash
73
+ # Terminal output (default)
74
+ ngcompass analyze
75
+
76
+ # Compact ESLint-style output (great for CI logs)
77
+ ngcompass analyze --format console --compact
78
+
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
82
+
83
+ # Interactive UI report (alias for html — same output)
84
+ ngcompass analyze --format ui
85
+
86
+ # Machine-readable JSON
87
+ ngcompass analyze --format json > results.json
88
+
89
+ # SARIF for GitHub Code Scanning
90
+ ngcompass analyze --format sarif > results.sarif
91
+ ```
92
+
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:
100
+
101
+ ```ts
102
+ import { defineConfig } from '@ngcompass/config';
103
+
104
+ export default defineConfig({
105
+ // Start from a preset: 'ngcompass:recommended' | 'ngcompass:strict' | 'ngcompass:performance' | 'ngcompass:reactivity' | 'ngcompass:all'
106
+ extends: 'ngcompass:recommended',
107
+
108
+ // Files to scan
109
+ include: [
110
+ 'src/**/*.ts',
111
+ 'src/**/*.html',
112
+ ],
113
+
114
+ exclude: [
115
+ 'node_modules/**',
116
+ 'dist/**',
117
+ 'build/**',
118
+ 'coverage/**',
119
+ '**/*.d.ts',
120
+ '**/*.spec.ts',
121
+ '**/*.test.ts',
122
+ ],
123
+
124
+ // Override individual rules
125
+ rules: {
126
+ 'prefer-on-push-component-change-detection': 'error',
127
+ 'no-document-access': 'warn',
128
+ },
129
+ });
130
+ ```
131
+
132
+ ### Presets
133
+
134
+ | Preset | Description |
135
+ |---|---|
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
143
+
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` |
156
+
157
+ ---
158
+
159
+ ## Commands
160
+
161
+ | Command | Description |
162
+ |---|---|
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 |
178
+
179
+ ### Analyze Options
180
+
181
+ | Option | Description |
182
+ |---|---|
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:
236
+
237
+ ```yaml
238
+ # GitHub Actions example
239
+ - name: Run ngcompass
240
+ run: ngcompass analyze --format sarif > results.sarif
241
+
242
+ - name: Upload to Code Scanning
243
+ uses: github/codeql-action/upload-sarif@v3
244
+ with:
245
+ sarif_file: results.sarif
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Caching
251
+
252
+ ngcompass caches analysis results between runs. Only changed files are re-analyzed, making subsequent runs significantly faster on large codebases.
253
+
254
+ ```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
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Packages
263
+
264
+ ngcompass is a monorepo. The CLI is published as `ngcompass`; internal libraries use the `@ngcompass` scope:
265
+
266
+ | Package | Description |
267
+ |---|---|
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 |
277
+ | [`@ngcompass/common`](packages/common) | Shared types and utilities |
278
+
279
+ ---
280
+
281
+ ## Requirements
282
+
283
+ - **Node.js** `^20.19.0` or `>=22.12.0`
284
+ - **Angular** v15 or later
285
+
286
+ ---
287
+
288
+ ## Known Limitations (Beta)
289
+
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
294
+
295
+ ---
296
+
297
+ ## License
298
+
299
+ MIT — see [LICENSE](./LICENSE)