[英]What is the point of the @angular-eslint/no-input-rename ESLint rule?
What is wrong with renaming an input property?重命名输入属性有什么问题? If I have the following component
如果我有以下组件
@Component({
selector: 'sc-heading',
templateUrl: './sc-heading.component.html',
styleUrls: ['./sc-heading.component.scss']
})
export class ScHeadingComponent {
@Input()
title: string;
@Input()
class: string;
@Input('columns')
set columnsSet(value: string | number) {
if (typeof value === 'string') {
this.columns = parseInt(value, 10);
} else {
this.columns = value;
}
}
columns = 1;
}
What is wrong with having an override for the columns property setter so it can take a string as an input and parse it?对列属性设置器进行覆盖有什么问题,以便它可以将字符串作为输入并解析它? I have just switched over to angular-eslint and it has a rule @angular-eslint/no-input-rename which is causing this to error.
我刚刚切换到 angular-eslint,它有一个规则 @angular-eslint/no-input-rename 导致这个错误。 I use this in multiple spots so I was wondering if there is anything wrong with this practice before I go and disable the rule.
我在多个地方使用它,所以在我 go 并禁用规则之前,我想知道这种做法是否有任何问题。
As described in Angular's Style Guide rules :如Angular 的样式指南规则中所述:
Two names for the same property (one private, one public) is inherently confusing... You should use an alias when the directive name is also an input property, and the directive name doesn't describe the property.
同一属性的两个名称(一个私有,一个公共)本质上是令人困惑的......当指令名称也是输入属性并且指令名称不描述该属性时,您应该使用别名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.