gulp-eslint 不在控制台上打印 linting 错误

gulp-tslint not printing linting erros on console

嗨,我正在尝试 运行 在小型 angular 2 应用程序上使用 gulp 的 tslint 任务,但它似乎 work.Here 不是我所拥有的远:

这是我的gulp文件:

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 终止。

我做错了什么?

我有一个类似的问题,其中 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 无法 运行 的配置错误已写入控制台,我能够修复我的配置。