Skip to content

Instantly share code, notes, and snippets.

@vast

vast/lint.js Secret

Last active January 26, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vast/3fb399e1d3b4d1a83c2b to your computer and use it in GitHub Desktop.
Save vast/3fb399e1d3b4d1a83c2b to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var MAX_ISSUES = 1000;
var CliEngine = require('eslint').CLIEngine;
var exec = require('child_process').exec;
var cli = new CliEngine();
var formatter = cli.getFormatter('stylish');
var report = cli.executeOnFiles(['**/*.js']);
var currentIssuesCount = report.errorCount + report.warningCount;
if (currentIssuesCount > MAX_ISSUES) {
console.log('Warning limit exceeded: ' + currentIssuesCount + '.');
console.log('Keep amount of warnings from eslint below ' + MAX_ISSUES + '.\n');
console.log('Errors in changed files: ');
exec('git diff --name-only master', function(_, stdout) {
var changedFiles = stdout.toString().split('\n').filter(function(filename) {
return filename.match(/\.js$/);
});
var reportOnChangesFiles = cli.executeOnFiles(changedFiles);
console.log(formatter(reportOnChangesFiles.results));
process.exit(1);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment