DEV Community

Your Angular tech debt can now fix itself - ahc fix

Three weeks ago I launched Angular Health Check - a CLI that scores your Angular project 0-100. It's at 1,200+ downloads now, and the #1 piece of feedback was brutally consistent: "Cool, it found 23 issues. Now what?" Fair. Detection without action is just guilt. So this release ships ahc fix.

Auto-fix

$ ahc fix . --dry-run
Would apply 12 fixes:
  ~ src/app/user-list.component.ts:8
    Added OnPush to "UserListComponent"
  ~ src/app/cart.service.ts:45
    Removed console.log('debug')

$ ahc fix .
โœ” 12 fixes applied. Review with git diff, then re-run ahc scan.

What it fixes today - deliberately conservative

  • Missing OnPush - inserts changeDetection: ChangeDetectionStrategy.OnPush plus the import. Real AST transform (ts-morph), not regex.
  • console.log - removed. console.warn/console.error stay (usually intentional), and console.log used as an expression value is never touched.
  • --dry-run first, always. And the CLI reminds you: OnPush changes rendering behavior - review the diff before committing.

Rules that know your Angular version

The scanner reads @angular/core from your package.json and gates rules accordingly:

  • Angular 14 detected - Signals rules skipped (requires Angular 16+)
  • No noise about input() migration on Angular 14
  • Rules light up as your version unlocks them

How far are you from modern Angular?

$ ahc migrate-check .
Modernization readiness - Angular 18
โœ” Standalone components              15/15
โœ” Signal inputs                       3/3
โœ” Built-in control flow              11/11
โ€ข OnPush change detection            13/15 โ†’ 2 components on default CD

Break the build when quality drops

- uses: piipe800/Angular-Health-Check/packages/action@main
  with:
    fail-under: 70

And PR comments now show the delta vs your base branch: โˆ’5 pts vs base branch (was 92).

Try it

No install needed:

npx @angular-health-check/cli scan .
# or
pnpm dlx @angular-health-check/cli scan .

What should ahc fix handle next? trackBy? @Input() โ†’ input() migration? The next fixer ships based on the comments.

Comments

No comments yet. Start the discussion.