简体   繁体   English

@angular-eslint/no-input-rename ESLint 规则有什么意义?

[英]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.

相关问题 Angular 9 + eslint:找不到规则“@angular-eslint/…”的错误定义 - Angular 9 + eslint: error Definition for rule '@angular-eslint/…' was not found 如何添加@angular-eslint/schematics? 错误 - How add @angular-eslint/schematics? Error angular-eslint 和 typescript-eslint 之间的区别 - Difference between angular-eslint and typescript-eslint 如何运行@angular-eslint/schematics:convert-tslint-to-eslint - How to run @angular-eslint/schematics:convert-tslint-to-eslint 将 @angular-eslint/template/eqeqeq 设置为 off 不适用于 angular 13 - Setting @angular-eslint/template/eqeqeq to off not working with angular 13 如何为 protractor 项目设置 angular-eslint? - How do I need to setup angular-eslint for a protractor project? 将 tslint 迁移到 @angular-eslint/schematics:ERESOLVE 无法解析依赖树:@angular/compiler@12.1.2 - Migrate tslint to @angular-eslint/schematics: ERESOLVE unable to resolve dependency tree: @angular/compiler@12.1.2 How do I install the right version of @angular-eslint/schematic to match my angular-compiler? - How do I install the right version of @angular-eslint/schematic to match my angular-compiler? 不支持:关键字“id”,使用“$id”作为模式 ID:TSLint(ng add @angular-eslint/schematics) - NOT SUPPORTED: keyword "id", use "$id" for schema ID : TSLint (ng add @angular-eslint/schematics) 在 Angular 中排除某些关键字和短语的 ESLint 规则? - ESLint Rule to Exclude Certain Keywords and Phrases in Angular?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM