Disallows string values for non-string attributes in Ionic components and suggests proper property binding. Supports boolean, number, and object type attributes.
- ✒️ The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
This rule prevents TypeScript build errors by detecting when string values are assigned to non-string attributes (boolean, number, object, complex) in Ionic component templates and suggests proper property binding.
This rule detects when string values are assigned to non-string attributes (boolean, number, object, complex) in Ionic component templates.
❌ Incorrect: Using string values for non-string attributes
<ion-item button="true"></ion-item>
<ion-list inset="true"></ion-list>
<ion-progress-bar value="50"></ion-progress-bar>
<input disabled="false"></input>
<button readonly="1"></button>✅ Correct: Using property binding
<ion-item [button]="true"></ion-item>
<ion-list [inset]="true"></ion-list>
<ion-progress-bar [value]="50"></ion-progress-bar>
<input [disabled]="false"></input>
<button [readonly]="true"></button>No Options.
This rule automatically identifies non-string attributes from Ionic component type definitions and detects attributes such as:
ion-item:button,disabled,detailion-list:inset,linesion-button:disabled,expand,fill,strongion-checkbox:checked,disabled,indeterminateion-toggle:checked,disabledion-radio:checked,disabledion-input:disabled,readonly,requiredion-textarea:disabled,readonly,requiredion-select:disabled,multiple,requiredion-datetime:disabled,readonlyion-range:disabled,pin,snapsion-segment:disabledion-slides:pager,scrollbarion-tab:selectedion-menu:disabled,swipeGestureion-modal:animated,backdropDismiss,showBackdropion-popover:animated,backdropDismiss,showBackdropion-alert:animated,backdropDismission-loading:animated,backdropDismission-toast:animatedion-action-sheet:animated,backdropDismiss
This rule displays the following message:
boolean attribute 'button' should not have a string value 'true'. Use property binding [button]="true" instead.
number attribute 'value' should not have a string value '50'. Use property binding [value]="50" instead.