angular-doctor 0.0.1-alpha.0

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 ADDED
@@ -0,0 +1,162 @@
1
+ # angular-doctor
2
+
3
+ Let coding agents diagnose and fix your Angular code.
4
+
5
+ One command scans your codebase for performance, correctness, architecture, and dead code issues, then outputs a **0–100 score** with actionable diagnostics.
6
+
7
+ ## How it works
8
+
9
+ Angular Doctor detects your Angular version and framework (Angular CLI, Nx, Ionic, AnalogJS, Angular SSR), then runs two analysis passes **in parallel**:
10
+
11
+ 1. **Lint**: Checks Angular-specific rules across components, directives, pipes, performance, architecture, and TypeScript quality.
12
+ 2. **Dead code**: Detects unused files, exports, and types using [knip](https://knip.dev).
13
+
14
+ Diagnostics are scored by severity to produce a **0–100 health score** (75+ Great, 50–74 Needs work, <50 Critical).
15
+
16
+ ## Workspace support
17
+
18
+ Angular Doctor automatically detects multiple projects in your workspace:
19
+
20
+ - **Angular CLI workspaces** — reads `angular.json` and scans each project inside `projects/`
21
+ - **npm / pnpm workspaces** — detects packages with `@angular/core` from `workspaces` field or `pnpm-workspace.yaml`
22
+
23
+ When multiple projects are found, Angular Doctor:
24
+ - **Interactive mode**: shows a multi-select prompt to choose which projects to scan
25
+ - **Non-interactive mode** (`-y / --yes`, CI): scans all detected projects automatically
26
+
27
+ Use `--project <name>` to target a specific project (comma-separated for multiple):
28
+
29
+ ```bash
30
+ npx -y angular-doctor@latest . --project my-app,my-lib
31
+ ```
32
+
33
+ ## Install
34
+
35
+ Run this at your Angular project root (or workspace root):
36
+
37
+ ```bash
38
+ npx -y angular-doctor@latest .
39
+ ```
40
+
41
+ Use `--verbose` to see affected files and line numbers:
42
+
43
+ ```bash
44
+ npx -y angular-doctor@latest . --verbose
45
+ ```
46
+
47
+ ## Options
48
+
49
+ ```
50
+ Usage: angular-doctor [directory] [options]
51
+
52
+ Options:
53
+ -v, --version display the version number
54
+ --no-lint skip linting
55
+ --no-dead-code skip dead code detection
56
+ --verbose show file details per rule
57
+ --score output only the score
58
+ -y, --yes skip prompts, scan all workspace projects
59
+ --project <name> select workspace project (comma-separated for multiple)
60
+ --diff [base] scan only files changed vs base branch
61
+ -h, --help display help for command
62
+ ```
63
+
64
+ ## Configuration
65
+
66
+ Create an `angular-doctor.config.json` in your project root to customize behavior:
67
+
68
+ ```json
69
+ {
70
+ "ignore": {
71
+ "rules": ["@angular-eslint/prefer-standalone"],
72
+ "files": ["src/generated/**"]
73
+ }
74
+ }
75
+ ```
76
+
77
+ You can also use the `"angularDoctor"` key in your `package.json`:
78
+
79
+ ```json
80
+ {
81
+ "angularDoctor": {
82
+ "ignore": {
83
+ "rules": ["@angular-eslint/prefer-standalone"]
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### Config options
90
+
91
+ | Key | Type | Default | Description |
92
+ |-----|------|---------|-------------|
93
+ | `ignore.rules` | `string[]` | `[]` | Rules to suppress using the `plugin/rule` format |
94
+ | `ignore.files` | `string[]` | `[]` | File paths to exclude, supports glob patterns |
95
+ | `lint` | `boolean` | `true` | Enable/disable lint checks |
96
+ | `deadCode` | `boolean` | `true` | Enable/disable dead code detection |
97
+ | `verbose` | `boolean` | `false` | Show file details per rule |
98
+ | `diff` | `boolean | string` | — | Scan only changed files |
99
+
100
+ ## Node.js API
101
+
102
+ ```typescript
103
+ import { diagnose } from "angular-doctor/api";
104
+
105
+ const result = await diagnose("./path/to/your/angular-project");
106
+
107
+ console.log(result.score); // { score: 82, label: "Great" }
108
+ console.log(result.diagnostics); // Array of Diagnostic objects
109
+ console.log(result.project); // Detected framework, Angular version, etc.
110
+ ```
111
+
112
+ Each diagnostic has the following shape:
113
+
114
+ ```typescript
115
+ interface Diagnostic {
116
+ filePath: string;
117
+ plugin: string;
118
+ rule: string;
119
+ severity: "error" | "warning";
120
+ message: string;
121
+ help: string;
122
+ line: number;
123
+ column: number;
124
+ category: string;
125
+ }
126
+ ```
127
+
128
+ ## Angular-specific rules
129
+
130
+ Angular Doctor checks the following categories of issues:
131
+
132
+ ### Components
133
+ - Missing `Component` / `Directive` class suffixes
134
+ - Empty lifecycle methods
135
+ - Missing lifecycle interfaces
136
+ - Pipe not implementing `PipeTransform`
137
+
138
+ ### Performance
139
+ - Missing `OnPush` change detection strategy
140
+ - Outputs shadowing native DOM events
141
+
142
+ ### Architecture
143
+ - Conflicting lifecycle hooks (`DoCheck` + `OnChanges`)
144
+ - Use of `forwardRef`
145
+ - Renamed inputs/outputs
146
+ - Inline `inputs`/`outputs` metadata properties
147
+ - Non-standalone components (Angular 17+)
148
+
149
+ ### TypeScript
150
+ - Explicit `any` usage
151
+
152
+ ### Dead Code
153
+ - Unused files
154
+ - Unused exports and types
155
+
156
+ ## Inspiration
157
+
158
+ This project is inspired by [react-doctor](https://github.com/millionco/react-doctor) — an equivalent tool for React codebases.
159
+
160
+ ## License
161
+
162
+ MIT
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };