"? 的 tslint 规则-6ren"> "? 的 tslint 规则-我对一些使用指令 ngb-pagination 的组件进行了 Angular 测试。来自 ng-bootstrap . 现在,在我的测试中,我模拟这个组件如下: // on next line I g-6ren">
gpt4 book ai didi

angular - 如何禁用 Angular 风格指南 : "The selector should be prefixed by "? 的 tslint 规则

转载 作者:行者123 更新时间:2023-12-04 12:25:27 26 4
gpt4 key购买 nike

我对一些使用指令 ngb-pagination 的组件进行了 Angular 测试。来自 ng-bootstrap .

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

// 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注释我得到一个指向 Style 02-07 的 tslint 错误.

我尝试通过执行以下操作来禁用该规则,但结果是一样的。
// tslint:disable-next-line:directive-selector
@Component({ template: ``, selector: 'ngb-pagination' })

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

PS:
  • 这是真正的angular project如果您想检查任何资源配置。
  • 有一个类似的问题( kebab-case in angular 2 selectors (tslint) ),但 OP 只是决定接受它。
  • 最佳答案

    您可以在 angular.json 中设置它里面的文件 scematics像这样进入:

    您可以为组件和指令设置它

    "schematics": {
    "@schematics/angular:component": {
    "prefix": ""
    },
    "@schematics/angular:directive": {
    "prefix": ""
    }
    }

    如果您使用命令行并且不经常生成组件/指令,则可以使用命令行执行此操作,如下所示:
    ng generate component my-component --prefix ""

    关于angular - 如何禁用 Angular 风格指南 : "The selector should be prefixed by <prefix>"? 的 tslint 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56587843/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com