简体   繁体   English

无法通过 Angular 模板上的 Codelyzer 禁用 tslint 规则

[英]Cannot disable tslint rule via Codelyzer on Angular Template

I have an Angular template that needs to call function by passing an index.我有一个 Angular 模板,需要通过传递索引来调用函数。 There is a Codelyzer rule "template-no-call-expression" that complains when I do this.当我这样做时,有一个 Codelyzer 规则“模板无调用表达式”会抱怨。

I have attempted to disable the rule in the typescript file, but it continues to fail the lint check.我试图禁用打字稿文件中的规则,但它仍然无法通过 lint 检查。 Is this a bug, or am I not doing it correctly?这是一个错误,还是我做得不正确?

/* tslint:disable: template-no-call-expression */
@Component({
...

Make sure the tslint-disabling is the FIRST line in your component.ts (so that means: above the imports)!确保 tslint-disabling 是你的 component.ts 中的第一行(所以这意味着:在导入之上)! I had the same problem and after reading the comment on the pull request below, I realized that if you put the disabling on line 17 of your TS, it will disable the check for all lines 17+ in your HTML file, but NOT for line 1 - 16 :\\我遇到了同样的问题,在阅读下面对拉取请求的评论后,我意识到如果您将禁用放在 TS 的第 17 行,它将禁用对 HTML 文件中所有 17+ 行的检查,但不会禁用对行的检查1 - 16 :\\

See comment on https://github.com/mgechev/codelyzer/pull/492请参阅https://github.com/mgechev/codelyzer/pull/492 上的评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 codelyzer和tslint有什么区别? - What is the difference between codelyzer and tslint? 如何禁用 Angular 样式指南的 tslint 规则:“选择器应以<prefix> “?</prefix> - How to disable tslint rule for Angular style guide: "The selector should be prefixed by <prefix>"? 带有 Angular 7 和 `ng lint` 的 TypeScript 中的自定义 TSLint 规则 - Custom TSLint Rule in TypeScript with Angular 7 and `ng lint` 如何在角度2中使用codelyzer - How to use codelyzer in angular 2 ng lint 找不到自定义规则目录:在 gitlab CI 上使用 Angular CLI 的 codelyzer - ng lint Could not find custom rule directory: codelyzer with Angular CLI on gitlab CI 如何禁用Angular的tslint错误Visual Studio? - How to disable tslint errors visual studio for Angular? tslint / codelyzer / ng lint 错误:“for (... in ...) 语句必须用 if 语句过滤” - tslint / codelyzer / ng lint error: “for (… in …) statements must be filtered with an if statement” 如何在Angular中定义枚举类型以不违反tslint typedef规则 - How to define enum type in Angular to not violating tslint typedef rule Angular TSLint - 找不到构建器“@angular-devkit/build-angular:tslint” - Angular TSLint - Cannot find builder "@angular-devkit/build-angular:tslint" Angular 12 从 tslint 切换到 eslint 后模板 linting 不起作用 - Angular 12 template linting not working after switchting from tslint to eslint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM