Skip to content

Rule proposal: no duplicate attributes #293

Closed
@mattlewis92

Description

@mattlewis92

When investigating switching from ViewEngine to ivy we stumbled on a problem where we had components with the same attribute being passed in twice and the behaviour is different between view engine and ivy. e.g. consider the component:

@Component({
  selector: 'foo',
  template: '{{ bar }}',
})
export class FooComponent {
  @Input() bar: string
}

Is used like this:

<foo [bar]="'bam'" [bar]="'baz'"></foo>

ViewEngine: uses the first input and prints bam
Ivy: uses the second input and prints baz

So I think this would make sense as a lint rule to detect these duplicate attributes so that they can be removed (usually they are added by accident by merge conflicts). I did a quick check with AST explorer and it looks like they are represented in the
AST so it should be possible to write a lint rule to detect them.

I would be happy to work on this myself, I think it should be straightforward to implement. If anyone has any suggestions on a descriptive name for the rule that would be very helpful 🚲

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs WelcomeIf a high-quality PR is created for this it will be acceptedenhancementNew feature or requestpackage: eslint-plugin-templateAngular Template rulesrule proposalThis issue is requesting/proposing the creation of a new rule within one of the core plugins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions