【问题标题】:gulp-tslint not printing linting erros on consolegulp-tslint 不在控制台上打印 linting 错误
【发布时间】:2016-10-31 18:41:29
【问题描述】:

您好,我正在尝试在一个小型 Angular 2 应用程序上使用 gulp 运行 tslint 任务,但它似乎不起作用。这是我目前所拥有的:

这是我的 gulpFile:

const gulp = require('gulp');
const tslint = require('gulp-tslint');

gulp.task('tslint', () => {
    return gulp.src("app/**/*.ts")
        .pipe(tslint({ configuration: "tslint.json" }))
        .pipe(tslint.report('verbose'));
});

为了确保我得到错误,我在 tslist.json 中设置了以下选项:"max-line-length": [ true, 5 ]

当我运行此任务时,我得到以下信息:

[10:29:54] Using gulpfile ~\Desktop\InovationWeek\InovationWeek\Gulpfile.js
[10:29:54] Starting 'tslint'...
Process terminated with code 1.

它没有说明它发现什么 linting 错误只是进程以代码 0 终止。

我做错了什么?

【问题讨论】:

    标签: gulp tslint


    【解决方案1】:

    我遇到了一个类似的问题,即 tslint 遇到了我的配置问题并且实际上没有执行任何 linting。

    这导致进程以代码 1 终止,但未返回任何 linting 错误,这似乎与您看到的问题相同。

    我的解决方案是在 gulp 中添加一些错误处理:

    gulp.task("tslint", function() {
      return gulp.src(config.tsSrc)
        .pipe(tslint({
          formatter: "verbose",
          configuration: "tslint.json"
        }))
        .on('error', printError)
        .pipe(tslint.report());
    });
    
    // print the error out
    var printError = function(error) {
      console.log(error.toString());
    }
    

    这意味着导致 tslint 无法运行的配置错误已写入控制台,我能够修复我的配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 2016-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      相关资源
      最近更新 更多