1

所以这是我的吞咽任务:

var gulp = require('gulp');
var eslint = require('gulp-eslint');
var reporter = require('eslint-html-reporter');
var fs = require('fs');
var path = require('path');


gulp.task('eslint:reporter', function () {
  var reportFile = path.join(__dirname, 'report-results.html');
  return gulp.src(['./src/**/*.js'])
  .pipe(eslint())
  .pipe(eslint.format(reporter, function (results) {
    fs.unlink(reportFile, function () {
      fs.writeFile(reportFile, results, function () {
        console.log('Done.');
      });
    });
  }));
});

gulp.task('eslint', ['eslint:reporter'], function() {
  gulp.watch(['./src/**/*.js'], ['eslint:reporter']);
});

基本上问题是gulp eslint在第一次运行后生成文件reporter-results.html。然后我去进行更改并重新运行。当我刷新页面时,报告的文件翻了一番。这份名单的每一个文件都翻了一番。为什么要保留这段历史?有没有办法从 eslint 中清除它?

4

0 回答 0