Consider the following use-case:
any-component.html
<my-cmp [myInput]="'xx'"></my-cmp>
my-component.ts
@Input('myInput')
myInput: any;
The no-input-rename rule doesn't shows warning in this case above.
So.. I'm just wondering if it's intentional or no... because in fact it doesn't make sense to write myInput inside the parentheses: @Input('myInput') instead of @Input()... besides writing more, it won't affect anything at all.
PS: the same is valid for no-output-rename.
This rule seems to be intentional if we peek at the class test :
should succeed, when a directive input property rename is the same as the name of the property
Because the Style Guide indicates :
Two names for the same property (one private, one public) is inherently confusing.
In your case, it's the same name...
But, the style guide indicates also :
You should use an alias when the directive name is also an input property, and the directive name doesn't describe the property.
It's a bit confusing ! Maybe, we can improve the style guide. @wardbell, what do you think about this ?
I think we can change Codelyzer in this direction. Are you agree @mgechev ?
@wKoza maybe different error messages depending on the value passed to @Input.
Regarding the style guide, yes, we can make the explanation more complete.
I think this also warrants taking another look at https://github.com/mgechev/codelyzer/issues/224.
The "Angular Fundamentals" specifically recommends aliasing an input variable to the directive selector
(https://angular.io/guide/attribute-directives#binding-to-an-input-property), so I really think Codelyzer should recognize this special case and not flag it as an error.
(I am aware that it can be selectively disabled, but it feels wrong to actively have to fight the linter to write idiomatic code).
ETA: The similar selector-name-postfixed-with-Changed for outputs should also be recognized.
Lets move it to the next milestone.
Most helpful comment
I think this also warrants taking another look at https://github.com/mgechev/codelyzer/issues/224.
The "Angular Fundamentals" specifically recommends aliasing an input variable to the directive selector
(https://angular.io/guide/attribute-directives#binding-to-an-input-property), so I really think Codelyzer should recognize this special case and not flag it as an error.
(I am aware that it can be selectively disabled, but it feels wrong to actively have to fight the linter to write idiomatic code).
ETA: The similar selector-name-postfixed-with-Changed for outputs should also be recognized.