-
-
Save vast/3fb399e1d3b4d1a83c2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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