panuhorsmalahti / gulp-tslint

TypeScript linter plugin for Gulp
MIT License
118 stars 44 forks source link

Add link for `gulp-reporter` #130

Closed gucong3000 closed 7 years ago

gucong3000 commented 7 years ago

gulp-reporter used in team project, it fails only when error belongs to the current author of git.

panuhorsmalahti commented 7 years ago

I don't quite understand this PR. Can you give a concrete example? Would it be sufficient for this information to be in the gulp-reporter repository?

gucong3000 commented 7 years ago

image This is a screenshot when I use gulp-reporter. Each error will display the author of which line of code it is in.(by git blame command) When some errors does not belong to you, their severity will be reduced to warning. In this screenshot, It runs in Git hook, all the error messages are not mine, so I can still commit my code.

This is a part of our gulpfile.js:

var reporter = require('gulp-reporter');
var eclint = require('eclint');
var eslint = require('gulp-eslint');
var fileType = require('file-type');
var filter = require('gulp-filter');
var git = require('gulp-git');
var gulpif = require('gulp-if');
var postcss = require('gulp-postcss');
var stylelint = require('stylelint');
var gulp = require('gulp');

function excludeBinaryFile(file) {
    return !(file && file.isBuffer() && fileType(file.contents));
}

function isEsFile(file) {
    return /\.(?:js|jsx|es\d*|vue)$/i.test(file.extname);
}

function isStyleFile(file) {
    return /\.(?:s?css|sass|less|sss)$/i.test(file.extname);
}

gulp.task('lint:git_diff', () => {
    return git.diff('origin/master...')
        .pipe(filter(excludeBinaryFile))
        .pipe(eclint.check())
        .pipe(gulpif(isEsFile, eslint()))
        .pipe(gulpif(isStyleFile, postcss([stylelint])))
        .pipe(reporter());  
});
panuhorsmalahti commented 7 years ago

This is an interesting feature, but I don't think it should be linked from gulp-tslint.

gucong3000 commented 7 years ago

In our team, many people do not want to use linter in project because it will bring many mistakes in stable code. What gulp-reporter want to do is filter outout of errors on the stable code lines.

panuhorsmalahti commented 7 years ago

The usual workflow should be that any code will have the linter errors fixed before commiting / shared to anyone else.

gucong3000 commented 7 years ago

Yes, you are right. But in a very big project that without any lint, lf you want to add tslint to build script, that is a very big job. There are so many error need to fix. That is why so many people do not use lint tool.

panuhorsmalahti commented 7 years ago

It's a fair point. One workaround is only adding the linter to a subset of the files at first.

gucong3000 commented 7 years ago

3 years ago, I got a new job, when I try to add jshint to a project, I found a js file, it has 3000+ lines. that is hard to fix. so I add it to ignore. But after some days, I see other peoples add codes to this file to skip lint.

gucong3000 commented 7 years ago

Only fail when error found by lint on code just add or modify. It is the main usage of gulp-reporter.