Ensures that there are no duplicate input properties or output event listeners
-
Type: problem
-
💡 Provides suggestions on how to fix issues (https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
The rule accepts an options object with the following properties:
interface Options {
/**
* Whether or not two-way data binding is allowed as an exception to the rule.
*
* Default: `true`
*/
allowTwoWayDataBinding?: boolean;
/**
* Input or output properties for which duplicate presence is allowed as an exception to the rule.
*
* Default: `[]`
*/
ignore?: string[];
}
The following examples are generated automatically from the actual unit tests within the plugin, so you can be assured that their behavior is accurate based on the current commit.
❌ - Toggle examples of incorrect code for this rule
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [name]="foo" [name]="bar">
~~~~~~~~~~~~ ~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [name]="foo" name="bar">
~~~~~~~~~~~~ ~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input name="foo" name="bar">
~~~~~~~~~~ ~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input (change)="foo($event)" (change)="bar($event)">
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [(ngModel)]="model" [(ngModel)]="otherModel">
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [name]="foo" [other]="bam" [name]="bar">
~~~~~~~~~~~~ ~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [name]="foo" [name]="bar" [name]="bam">
~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [(ngModel)]="model" [name]="foo" [(ngModel)]="otherModel" name="bar">
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input (@fade.start)="animationStarted($event)" (@fade.start)="animationStarted($event)">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input (window:resize)="windowResized($event)" (resize)="resize()" (window:resize)="windowResized2($event)">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error",
{
"allowTwoWayDataBinding": false
}
]
}
}
<input [(ngModel)]="model" (ngModelChange)="modelChanged()">
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error",
{
"ignore": [
"class"
]
}
]
}
}
<input [name]="foo" class="css-static" name="bar" [class]="dynamic">
~~~~~~~~~~~~ ~~~~~~~~~~
✅ - Toggle examples of correct code for this rule
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input name="foo">
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [name]="foo">
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input (change)="bar()">
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [(ngModel)]="foo">
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<input [(ngModel)]="model" (ngModelChange)="modelChanged()">
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<div (@fade.start)="animationStarted($event)" (@fade.done)="animationDone($event)"></div>
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<div (window:keydown)="windowKeydown($event)" (document:keydown)="documentKeydown($event)" (document:keyup)="documentKeyup($event)" (keyup)="keyup($event)" (keydown)="keydown($event)"></div>
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<div [style.width.px]="col.width" [width]="col.width"></div>
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<button [class.disabled]="!enabled" [disabled]="!enabled"></button>
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<button [@.disabled]="!enabled" [.disabled]="!enabled"></button>
{
"rules": {
"@angular-eslint/template/no-duplicate-attributes": [
"error"
]
}
}
<div [style.width]="col.width + 'px'" [width]="col.width"></div>