4

我刚刚使用@angular/cli(最新版本 - 1.1.3)创建了一个新项目,但我遇到了一些关于 codelyzer 的问题。

让我们看看我现在拥有的代码:

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  private title = 'app'; // Should warn here
}

app.component.css:

spam { // Intentionally wrong to warn errors
  color: red;
}

app.component.html:

<h1>Welcome to {{title}}!!</h1>

tslint.json:(仅 codelyzer 部分):

"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true,
"no-unused-css": true

跑完之后ng lint

实际行为:

所有文件都通过 linting。

预期行为:

警告规则“templates-use-public”:

  • HTML 中使用了一个私有变量;

警告规则“no-unused-css”:

  • CSS 没有被使用;

请注意,这些示例只是我尝试过的几个示例。事实上, codelyzer似乎没有观察或报告.css.html文件中的任何错误。

我错过了什么吗?提前致谢。

4

0 回答 0