-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for --quiet option #57
Conversation
I can see your point and appreciate the PR; though, I believe this may be better implemented via Here's a quick example of what works now: gulp.task('warnless', function() {
return gulp.src(['**/*.js', '!node_modules/**', '!coverage/**'])
.pipe(eslint())
// format/formatEach can be used to transform reports as well
.pipe(eslint.format(function (reports) {
// count & remove warning messages from each eslint file report
reports.forEach(function (report) {
report.messages = report.messages.filter(function isError(message) {
return message.fatal || message.severity > 1;
});
});
// The returned value goes to the console (by default)
// If nothing is returned, nothing is written.
return '(Eslint Report Silenced)';
}))
// Now, we'll print what remains of the eslint reports
.pipe(eslint.format());
}); Does this work for you or what else might be done? |
That would do the work and produce the result I want. I can definitely live with that solution. One could however argue that the formats job should be to only format the data for different consumers and respect data integrity. The fact that grunt-eslint supports it maybe also is a carrot? ;) Making it an option also makes it easier to receive argvs from outside gulp land. You could do things like:
and in gulp task do:
Anyway, thanks for getting back on this. |
@adametry Thanks for the snippit. I have to agree with @anddoutoi though - this would be nice to have as a baked-in feature rather than a special formatter (my guess is that most people would not know to find this GitHub Issue, and just assume it is impossible if it isn't in the docs). |
What do you think about having an option var fileOut = fs.createWriteStream('lint-errors.log');
gulp.src('**/*.js')
.pipe(eslint())
.pipe(eslint.format()); // print errors and warnings to stdout
.pipe(eslint.format(2, 'compact', fileOut)); // print errors (severity = 2) to file Note: the severity numbers are the same as the ones used when configuring eslint rules. This would be more flexible in how the data is consumed and maintain data integrity (with no reduction). |
Has there been any progress on this? |
A release candidate has been published that includes a "quiet" option. If set to gulp.task('lint-quiet', function () {
return gulp.src('src/**/*.js')
.pipe(eslint({quiet: true}))
.pipe(eslint.format());
}); ...or only warnings: function isWarning(message) {
return message.severity === 1;
}
gulp.task('lint-warn', function () {
return gulp.src('src/**/*.js')
.pipe(eslint({quiet: isWarning}))
.pipe(eslint.format());
}); Try the release candidate out and let me know how well it works for you. npm install gulp-eslint@rc |
The option is now in the latest version of gulp-eslint (1.1.0). |
The command line interface of ESLint supports --quiet to only report errors and ignore warnings. The ESLint CLIEngine do not expose this option because quiet only has to do with output and CLIEngine is designed specifically to not output anything.
This is is useful when you lint something where warnings don't matter e.g. a git pre-commit hook. It can be confusing to see a lot of warnings and still see the commit run.
Let me know if there is a better place or a better way to do this =)