@archlinter/cli 0.9.0 → 0.10.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.
Files changed (2) hide show
  1. package/README.md +56 -366
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -88,19 +88,21 @@ Built-in presets that understand framework patterns:
88
88
 
89
89
  ## Installation
90
90
 
91
- ### From source
91
+ ### Using npm (Recommended)
92
92
 
93
93
  ```bash
94
- git clone https://github.com/yourusername/archlint.git
95
- cd archlint
96
- cargo build --release
97
- cargo install --path .
94
+ npm install -g @archlinter/cli
95
+ # or use without installation
96
+ npx @archlinter/cli scan
98
97
  ```
99
98
 
100
- ### Using Cargo
99
+ ### From source
101
100
 
102
101
  ```bash
103
- cargo install archlint
102
+ git clone https://github.com/superprotocol/archlint.git
103
+ cd archlint
104
+ cargo build --release
105
+ cargo install --path crates/archlint
104
106
  ```
105
107
 
106
108
  ## Quick Start
@@ -114,7 +116,7 @@ archlint scan ./my-project
114
116
  ### With configuration
115
117
 
116
118
  ```bash
117
- archlint scan ./my-project --config archlint.yaml
119
+ archlint scan ./my-project --config .archlint.yaml
118
120
  ```
119
121
 
120
122
  ### Watch mode for development
@@ -150,390 +152,84 @@ archlint scan --detectors cycles,god_module,dead_code
150
152
  ### Exclude detectors
151
153
 
152
154
  ```bash
153
- archlint scan --exclude-detectors barrel_file_abuse,lcom
155
+ archlint scan --exclude-detectors barrel_file,lcom
154
156
  ```
155
157
 
156
158
  ## Configuration
157
159
 
158
- Create `archlint.yaml` in your project root:
160
+ Create `.archlint.yaml` in your project root:
159
161
 
160
162
  ```yaml
161
163
  # Files/directories to ignore
162
164
  ignore:
163
- - '**/*.test.ts'
164
- - '**/*.spec.ts'
165
- - '**/__tests__/**'
166
- - '**/__mocks__/**'
167
165
  - '**/node_modules/**'
168
166
  - '**/dist/**'
169
167
 
170
168
  # Path aliases (from tsconfig.json)
171
169
  aliases:
172
170
  '@/*': 'src/*'
173
- '@components/*': 'src/components/*'
174
- '@utils/*': 'src/utils/*'
175
171
 
176
172
  # Entry points (won't be marked as dead code)
177
173
  entry_points:
178
174
  - 'src/main.ts'
179
- - 'src/index.ts'
180
- - '**/*.e2e.ts'
181
- - '**/pages/**' # Next.js pages
182
175
 
183
- # Detector thresholds
184
- thresholds:
185
- god_module:
186
- fan_in: 10 # Max incoming dependencies
187
- fan_out: 10 # Max outgoing dependencies
188
- churn: 20 # Max git commits
176
+ # Rule-specific configuration
177
+ rules:
178
+ cycles: error
189
179
 
190
- hub_module:
180
+ god_module:
181
+ severity: high
191
182
  fan_in: 15
192
183
  fan_out: 15
193
-
194
- high_coupling:
195
- max_dependencies: 15
196
-
197
- lcom:
198
- threshold: 0.8 # 0-1 scale (higher = worse cohesion)
199
-
200
- deep_nesting:
201
- max_depth: 4
202
-
203
- long_params:
204
- max_params: 5
184
+ churn: 20
185
+
186
+ layer_violation:
187
+ severity: error
188
+ layers:
189
+ - name: domain
190
+ path: '**/domain/**'
191
+ allowed_imports: []
192
+ - name: application
193
+ path: '**/application/**'
194
+ allowed_imports: ['domain']
205
195
 
206
196
  complexity:
207
197
  max_complexity: 15
208
198
 
209
- # Framework detection (auto-detected, can override)
210
- frameworks:
211
- - nestjs
212
- - react
213
-
214
- # Layer architecture (for layer_violation detector)
215
- layers:
216
- - name: domain
217
- paths: ['**/domain/**']
218
- can_import: []
219
-
220
- - name: application
221
- paths: ['**/application/**', '**/use-cases/**']
222
- can_import: ['domain']
223
-
224
- - name: infrastructure
225
- paths: ['**/infrastructure/**', '**/adapters/**']
226
- can_import: ['domain', 'application']
227
-
228
- - name: presentation
229
- paths: ['**/controllers/**', '**/api/**']
230
- can_import: ['application', 'domain']
231
-
232
- # Severity overrides
233
- severity:
234
- cycles: critical
235
- god_module: high
236
- dead_code: low
237
- barrel_file_abuse: medium
238
- ```
239
-
240
- ## Available Detectors
241
-
242
- Run `archlint detectors list` to see all detectors with descriptions.
243
-
244
- | Detector | Description | Default Enabled |
245
- | ------------------------ | ---------------------------------------------- | --------------- |
246
- | `cycles` | Circular dependencies between files | ✅ |
247
- | `circular_type_deps` | Type-level circular dependencies | ✅ |
248
- | `god_module` | Modules with too many responsibilities | ✅ |
249
- | `hub_module` | Hub-like modules with high connectivity | ✅ |
250
- | `dead_code` | Unused exports | ✅ |
251
- | `dead_symbols` | Unused local functions and variables | ✅ |
252
- | `orphan_types` | Types not connected to codebase | ✅ |
253
- | `lcom` | Low cohesion in classes (LCOM4 metric) | ✅ |
254
- | `high_coupling` | Files with too many dependencies | ✅ |
255
- | `layer_violation` | Architectural layer violations | ⚠️ Framework |
256
- | `sdp_violation` | Stable Dependencies Principle violations | ⚠️ Framework |
257
- | `barrel_file_abuse` | Barrel files causing unnecessary coupling | ✅ |
258
- | `scattered_module` | Related functionality scattered across files | ✅ |
259
- | `scattered_config` | Configuration spread across codebase | ✅ |
260
- | `feature_envy` | Methods using more of another class | ✅ |
261
- | `shotgun_surgery` | Changes requiring modifications in many places | ✅ |
262
- | `primitive_obsession` | Overuse of primitives vs domain objects | ✅ |
263
- | `long_params` | Functions with too many parameters | ✅ |
264
- | `deep_nesting` | Deeply nested code blocks | ✅ |
265
- | `complexity` | High cyclomatic complexity | ✅ |
266
- | `side_effect_import` | Imports with side effects | ✅ |
267
- | `test_leakage` | Test code leaking into production | ✅ |
268
- | `vendor_coupling` | Tight coupling to external libraries | ✅ |
269
- | `unstable_interface` | Frequently changing public interfaces | ✅ |
270
- | `shared_mutable_state` | Shared mutable state between modules | ✅ |
271
- | `abstractness_violation` | Pain/Useless zones (I+A metric) | ✅ |
272
- | `package_cycle` | Cyclic dependencies between packages | ✅ |
273
-
274
- ## Example Output
275
-
276
- ### Table Format (Default)
277
-
278
- ```
279
- ╭─────────────────────────────────────────────────────────────────────────╮
280
- │ Architecture Smell Report │
281
- ├─────────────────────────────────────────────────────────────────────────┤
282
- │ Files analyzed: 247 │
283
- │ Smells detected: 12 │
284
- │ Total issues: 18 │
285
- ╰─────────────────────────────────────────────────────────────────────────╯
286
-
287
- ╭───────────────┬──────────────────────────────┬──────────┬─────────────╮
288
- │ Severity │ Smell │ File │ Score │
289
- ├───────────────┼──────────────────────────────┼──────────┼─────────────┤
290
- │ 🔴 CRITICAL │ Cyclic Dependency │ a.ts │ 95 │
291
- │ │ │ b.ts │ │
292
- │ │ │ c.ts │ │
293
- ├───────────────┼──────────────────────────────┼──────────┼─────────────┤
294
- │ 🟠 HIGH │ God Module │ utils.ts │ 87 │
295
- │ │ Fan-in: 23, Fan-out: 15 │ │ │
296
- ├───────────────┼──────────────────────────────┼──────────┼─────────────┤
297
- │ 🟡 MEDIUM │ Low Cohesion (LCOM) │ user.ts │ 65 │
298
- │ │ LCOM4: 0.85 │ │ │
299
- ╰───────────────┴──────────────────────────────┴──────────┴─────────────╯
300
- ```
301
-
302
- ### Markdown Format
303
-
304
- ### Markdown Format
305
-
306
- See full example with Mermaid diagrams in generated reports.
307
-
308
- ## CLI Reference
309
-
310
- ```bash
311
- # Scan commands
312
- archlint scan [PATH] # Scan project
313
- --config <FILE> # Config file path
314
- --format <table|markdown|json> # Output format
315
- --json # Shortcut for --format json (automatically enables --quiet)
316
- --report <FILE> # Save to file (default: stdout)
317
- --no-diagram # Disable Mermaid diagrams
318
- --all # Run all detectors (including disabled)
319
- --detectors <IDS> # Only run specific detectors
320
- --exclude-detectors <IDS> # Exclude specific detectors
321
- --min-severity <low|medium|high|critical> # Filter by severity
322
- --min-score <SCORE> # Filter by score (0-100)
323
- --quiet # CI-friendly mode (no progress bars)
324
- --verbose # Detailed output
325
- --no-cache # Disable caching
326
-
327
- # Watch mode
328
- archlint watch # Watch for changes
329
- --debounce <MS> # Debounce time (default: 300ms)
330
- --clear # Clear screen on re-run
331
- --ignore <PATTERN> # Additional ignore patterns
332
- [all scan options] # Accepts all scan options
333
-
334
- # Detector management
335
- archlint detectors list # List all available detectors
336
-
337
- # Cache management
338
- archlint cache clear # Clear analysis cache
339
- ```
340
-
341
- ## Performance
342
-
343
- - **Fast**: ~200 files analyzed in under 5 seconds
344
- - **Parallel**: Uses Rayon for multi-threaded analysis
345
- - **Cached**: Content-based caching (SHA256) for instant re-runs
346
- - **Efficient**: AST parsing with `oxc` (faster than Babel/SWC)
347
- - **Low memory**: Streaming analysis, no full AST kept in memory
348
-
349
- ## Framework Support
350
-
351
- ### NestJS
352
-
353
- - Controllers/Modules recognized as entry points
354
- - Relaxed coupling rules for modules/repositories
355
- - SDP and layer violation checks enabled
356
- - Ignores NestJS-specific decorators in LCOM
357
-
358
- ### Next.js
359
-
360
- - Pages and API routes as entry points
361
- - Barrel file rules relaxed (common pattern)
362
- - Layer violation checks disabled
363
-
364
- ### React
365
-
366
- - Components recognized by naming patterns
367
- - LCOM checks disabled (not applicable)
368
- - Scattered module checks relaxed
369
-
370
- ### oclif
371
-
372
- - CLI commands/hooks as entry points
373
- - Appropriate checks for CLI patterns
374
-
375
- ## Use Cases
376
-
377
- ### 🚀 CI/CD Integration
378
-
379
- ```yaml
380
- # .github/workflows/architecture.yml
381
- - name: Architecture Check
382
- run: |
383
- archlint scan --format json --report arch-report.json --min-severity high
384
- if [ $(jq '.summary.total_issues' arch-report.json) -gt 0 ]; then
385
- exit 1
386
- fi
387
- ```
388
-
389
- ### 🔄 Pre-commit Hook
199
+ # Rule overrides for specific paths
200
+ overrides:
201
+ - files: ['**/tests/**']
202
+ rules:
203
+ complexity: off
204
+ god_module: off
390
205
 
391
- ```bash
392
- # .git/hooks/pre-commit
393
- #!/bin/bash
394
- archlint scan --quiet --min-severity critical
395
- ```
396
-
397
- ### 📊 Regular Architecture Audits
398
-
399
- ```bash
400
- # Generate weekly reports
401
- archlint scan --format markdown --report "reports/$(date +%Y-%m-%d).md"
402
- ```
206
+ # Scoring and grading settings
207
+ scoring:
208
+ minimum: warn
209
+ weights:
210
+ critical: 100
211
+ high: 50
212
+ medium: 20
213
+ low: 5
403
214
 
404
- ### 🧹 Refactoring Guidance
405
-
406
- ```bash
407
- # Find high-priority issues
408
- archlint scan --min-score 80 --format table
409
-
410
- # Focus on specific problems
411
- archlint scan --detectors cycles,god_module,high_coupling
215
+ # Framework preset
216
+ framework: nestjs
412
217
  ```
413
218
 
414
- ## Comparison with Other Tools
415
-
416
- | Feature | archlint | madge | dependency-cruiser | ts-unused-exports | ArchUnit (Java) |
417
- | ---------------- | -------- | --------- | ------------------ | ----------------- | --------------- |
418
- | Language | TS/JS | TS/JS | TS/JS | TS/JS | Java |
419
- | Circular deps | ✅ | ✅ | ✅ | ❌ | ✅ |
420
- | Dead code | ✅ | ❌ | ❌ | ✅ | ❌ |
421
- | God modules | ✅ | ❌ | ❌ | ❌ | ⚠️ Custom rules |
422
- | LCOM/Cohesion | ✅ | ❌ | ❌ | ❌ | ⚠️ Custom rules |
423
- | Layer violations | ✅ | ❌ | ✅ | ❌ | ✅ |
424
- | Framework-aware | ✅ | ❌ | ⚠️ Limited | ❌ | ✅ |
425
- | Watch mode | ✅ | ✅ | ✅ | ❌ | ❌ |
426
- | AST-based | ✅ (oxc) | ⚠️ (slow) | ✅ | ✅ | ✅ |
427
- | Performance | ⚡ <5s | 🐌 ~30s | 🚀 ~10s | ⚡ ~5s | N/A |
428
- | 30+ detectors | ✅ | ❌ | ❌ | ❌ | ⚠️ Custom |
429
-
430
- **Key differentiators:**
431
-
432
- - **Comprehensive**: 30+ architectural smell detectors vs competitors' narrow focus
433
- - **Fast**: Rust + oxc parser = 5-10x faster than JS-based tools
434
- - **Smart**: Framework-aware analysis (NestJS, Next.js, React, oclif)
435
- - **Actionable**: Severity scores, explanations, and refactoring recommendations
436
- - **Modern**: Type-level cycle detection, abstractness metrics, SDP violations
437
-
438
- ## Architecture
439
-
440
- ```
441
- archlint
442
- ├── scanner # File discovery with .gitignore support
443
- ├── parser # AST parsing (oxc) + dependency extraction
444
- ├── resolver # Path resolution (aliases, node_modules)
445
- ├── graph # Dependency graph (petgraph)
446
- ├── detectors # 30+ smell detectors
447
- ├── framework # Framework detection & presets
448
- ├── engine # Analysis orchestration
449
- ├── metrics # Code metrics (LCOM, complexity, etc.)
450
- ├── cache # Content-based caching
451
- └── report # Output formatters (table, markdown, json)
452
- ```
453
-
454
- ## Contributing
455
-
456
- Contributions welcome! Areas for improvement:
457
-
458
- - [ ] More detectors (data clumps, speculative generality, etc.)
459
- - [ ] Support for other languages (Python, Go, Java)
460
- - [ ] HTML interactive reports
461
- - [ ] VS Code extension
462
- - [ ] Auto-fix suggestions
463
- - [ ] More framework presets (Angular, Vue, Svelte)
464
-
465
- ### Adding a Detector
466
-
467
- ```rust
468
- use crate::framework::detector::{Detector, DetectorMetadata, Smell};
469
- use inventory::submit;
470
-
471
- pub struct MyDetector;
472
-
473
- impl Detector for MyDetector {
474
- fn metadata(&self) -> DetectorMetadata {
475
- DetectorMetadata {
476
- id: "my_detector",
477
- name: "My Detector",
478
- description: "Detects something bad",
479
- severity: crate::framework::detector::Severity::Medium,
480
- enabled_by_default: true,
481
- }
482
- }
483
-
484
- fn detect(&self, context: &crate::engine::context::Context) -> Vec<Smell> {
485
- // Your detection logic here
486
- vec![]
487
- }
488
- }
489
-
490
- submit! { &MyDetector as &dyn Detector }
491
- ```
492
-
493
- ## Roadmap
494
-
495
- - [x] Core detectors (cycles, god modules, dead code)
496
- - [x] Framework detection (NestJS, Next.js, React)
497
- - [x] Watch mode
498
- - [x] Caching
499
- - [x] 30+ detectors
500
- - [ ] Auto-fix suggestions
501
- - [ ] VS Code extension
502
- - [ ] HTML reports with interactive graphs
503
- - [ ] Python/Go support
504
- - [ ] Trend analysis (track metrics over time)
505
- - [ ] Integration with SonarQube/CodeClimate
506
-
507
- ## Troubleshooting
508
-
509
- ### Parser errors
510
-
511
- ```bash
512
- # Enable verbose logging
513
- RUST_LOG=debug archlint scan --verbose
514
- ```
515
-
516
- ### Slow analysis
517
-
518
- ```bash
519
- # Check cache status
520
- ls -lh .smell-lens-cache/
219
+ ## Available Detectors
521
220
 
522
- # Clear cache if stale
523
- archlint cache clear
221
+ Run `archlint detectors list` to see all detectors with descriptions.
524
222
 
525
- # Use --quiet to disable progress bars
526
- archlint scan --quiet
527
- ```
223
+ | ID | Name | Default Enabled |
224
+ | ----------------- | --------------------- | --------------- |
225
+ | `cycles` | Circular Dependencies | ✅ |
226
+ | `god_module` | God Module | ✅ |
227
+ | `dead_code` | Dead Code | ✅ |
228
+ | `layer_violation` | Layer Violation | ⚠️ |
229
+ | `complexity` | High Complexity | ✅ |
230
+ | ... | ... | ... |
528
231
 
529
- ### False positives
530
-
531
- ```yaml
532
- # Adjust thresholds in archlint.yaml
533
- thresholds:
534
- god_module:
535
- fan_in: 20 # Increase threshold
536
- ```
232
+ [→ See full list of detectors](https://archlinter.github.io/archlint/detectors/)
537
233
 
538
234
  ## License
539
235
 
@@ -542,10 +238,4 @@ MIT License - see [LICENSE](LICENSE) for details.
542
238
  ## Credits
543
239
 
544
240
  - Built with [oxc](https://oxc-project.github.io/) - blazingly fast JS/TS parser
545
- - Inspired by [ArchUnit](https://www.archunit.org/), [madge](https://github.com/pahen/madge), [dependency-cruiser](https://github.com/sverweij/dependency-cruiser)
546
- - Academic foundations: Robert C. Martin's stability metrics, LCOM4 cohesion metric
547
-
548
- ## Contact
549
-
550
- - Issues: [GitHub Issues](https://github.com/yourusername/archlint/issues)
551
- - Discussions: [GitHub Discussions](https://github.com/yourusername/archlint/discussions)
241
+ - Inspired by [ArchUnit](https://www.archunit.org/), [madge](https://github.com/pahen/madge)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archlinter/cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Fast architecture smell detector for TypeScript/JavaScript",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,12 +21,12 @@
21
21
  "README.md"
22
22
  ],
23
23
  "optionalDependencies": {
24
- "@archlinter/cli-darwin-arm64": "0.9.0",
25
- "@archlinter/cli-darwin-x64": "0.9.0",
26
- "@archlinter/cli-linux-x64": "0.9.0",
27
- "@archlinter/cli-linux-arm64": "0.9.0",
28
- "@archlinter/cli-linux-x64-musl": "0.9.0",
29
- "@archlinter/cli-win32-x64": "0.9.0"
24
+ "@archlinter/cli-darwin-arm64": "0.10.0",
25
+ "@archlinter/cli-darwin-x64": "0.10.0",
26
+ "@archlinter/cli-linux-x64": "0.10.0",
27
+ "@archlinter/cli-linux-arm64": "0.10.0",
28
+ "@archlinter/cli-linux-x64-musl": "0.10.0",
29
+ "@archlinter/cli-win32-x64": "0.10.0"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=18"