eslint-travis-wrapper 875 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env node
  2. /* eslint no-console:0 import/no-nodejs-modules:0 */
  3. /* global process */
  4. const fs = require('fs');
  5. const CLIEngine = require('eslint').CLIEngine;
  6. const argv = process.argv.slice(2);
  7. const cli = new CLIEngine({
  8. fix: false,
  9. extensions: argv[1].split(','),
  10. useEslintrc: true,
  11. });
  12. // Lint all files
  13. const report = cli.executeOnFiles(argv.slice(3));
  14. // get the default formatter
  15. const consoleFormatter = cli.getFormatter();
  16. const otherFormatterType = argv.indexOf('--format=checkstyle') > -1 ? 'checkstyle' : null;
  17. // output to console
  18. console.log(consoleFormatter(report.results));
  19. // Output to checkstyle format for zeus
  20. if (otherFormatterType) {
  21. const otherFormatter = cli.getFormatter(otherFormatterType);
  22. fs.writeFile('eslint.checkstyle.xml', otherFormatter(report.results), 'utf8', () => {
  23. process.exit(report.errorCount);
  24. });
  25. }