在我的Angular应用程序中,我测试时使用的组件很少,而且不包含在任何模块中。
在WebStorm中,它显示了一个lint错误说Component is not included in any module
,而我知道这不包括在内,这就是目的。
有没有办法在禁用所有其他错误的同时禁用此lint错误?
Angular:组件'ComponentName'未包含在模块中 将无法在模板中使用。考虑将其添加到 NgModule声明。
我看到this threat,建议禁用所有Angular lint错误。但是,我认为仅针对一个问题做这件事并不是一个好主意。我正在寻找一种方法来只禁用这一个错误。
答案 0 :(得分:3)
Angular语言服务不提供禁止特定规则/检查的可能性。请关注https://github.com/angular/angular/issues/13726了解更新
答案 1 :(得分:2)
为我工作:
文件->使缓存无效/重新启动->使并重新启动无效
答案 2 :(得分:2)
我使用 PHPStorm ,并且在使用Angular 4时也发现了此问题。我通过npm install @angular/language-service
对其进行了修复。
答案 3 :(得分:0)
在Webstorm上,您只需按Alt+Enter
,它就会显示一个列表,您可以在其中选择disable inspection
,它会自动更新所有相同案例的检查规则。
答案 4 :(得分:0)
您可以在类声明上方添加以下注释,它将跳过对该类的检查:
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleSignUp = this.handleSignUp.bind(this);
this.state = {startDate: props.value};
}
您还可以通过使用将鼠标悬停在错误上时获得的上下文菜单并转到“检查选项>禁止陈述”来使编辑器为您添加该注释。