Search code examples
angularif-statementangular17

Is there a way to prevent the usage of *ngIf in favor of @if


Angular introduced the control flow blocks in v17 (@if, @for, @switch, etc.)

We migrated the entirety of our application to this new syntax and we are now wondering if there is any integrated option in Angular to prevent the use of *ngIf and only allow the use of the new syntax exclusively ?

Or should we adapt our linter configuration with a custom rule ?

Searched for an existing option online or an alternative without success.


Solution

  • The best way to do it is through linter.

    Angular 17.1.0 provides exactly that.

    You can add the rule @angular-eslint/template/prefer-control-flow to your eslint configuration.