You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

@angular/cli 6.0中tslint的TeamCity格式化功能失效怎么解决

解决Angular CLI 6+中配置TeamCity风格Lint输出的问题

别担心,这事儿我熟,Angular CLI 6之后换了lint的底层构建器,原来直接用--format指定第三方报告器的路子确实走不通了,不过咱们几步就能把tslint-teamcity-reporter找回来:

步骤1:确保依赖安装到位

先确认你还保留着tslint-teamcity-reporter,如果之前卸载了,重新装一下:

npm install tslint-teamcity-reporter --save-dev
# 用yarn的话就执行这个
yarn add tslint-teamcity-reporter --dev

步骤2:修正angular.json的lint配置

你之前的配置里用了format字段,但新构建器认的是formatter字段来指定自定义报告器。把你的lint配置改成这样:

"lint": {
  "builder": "@angular-devkit/build-angular:tslint",
  "options": {
    "tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
    "exclude": ["**/node_modules/**"]
  },
  "configurations": {
    "teamcity": {
      "formatter": "tslint-teamcity-reporter"
    }
  }
}

步骤3:执行TeamCity风格的Lint检查

现在运行这条命令就能生成TeamCity兼容的输出了:

ng lint --configuration teamcity

要是不想每次都用配置项,直接用命令行临时指定也行:

ng lint --formatter tslint-teamcity-reporter

本质上是因为新的@angular-devkit/build-angular:tslint构建器支持直接调用符合TSLint格式化器接口的第三方npm包,tslint-teamcity-reporter刚好满足这个要求,所以这么配置就能正常工作啦。

内容的提问来源于stack exchange,提问作者lucassp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:20:44