如何禁用 Angular 样式指南的 tslint 规则:“选择器应以 为前缀”?

2024-05-21

我对某些使用该指令的组件进行了 Angular 测试ngb-pagination from ng-引导程序 https://ng-bootstrap.github.io/#/home.

现在,在我的测试中,我模拟这个组件如下:

// on next line I get: The selector should be prefixed by "<prefix>" (https://angular.io/guide/styleguide#style-02-07) (component-selector)
@Component({ template: ``, selector: 'ngb-pagination' })
class DummyNgPagination {
    // some data here, not relevant in to the question
}

在它所在的行中@Component注释我得到一个tslint错误指向款式02-07 https://angular.io/guide/styleguide#style-02-07.

我尝试通过执行以下操作来禁用该规则,但结果是相同的。

// tslint:disable-next-line:directive-selector
@Component({ template: ``, selector: 'ngb-pagination' })

如何禁用该特定行的该规则?

PS:

  • 这是真实的角度项目 https://github.com/lealceldeiro/gms/tree/master/client如果您想检查任何资源配置。
  • 有一个类似的问题(Angular 2 选择器中的 kebab-case (tslint) https://stackoverflow.com/q/41732207/5640649)但OP决定忍受它。

规则directive-selector@Directive装饰师。

For a @Component你需要使用component-selector

例如:

// tslint:disable-next-line:component-selector
@Component({ template: ``, selector: 'ngb-pagination' })
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何禁用 Angular 样式指南的 tslint 规则:“选择器应以 为前缀”? 的相关文章

随机推荐