Skip to content

Instantly share code, notes, and snippets.

@pyrsmk
Created July 23, 2019 14:02
Show Gist options
  • Save pyrsmk/4c61e7d0ed27689553b097fa51356711 to your computer and use it in GitHub Desktop.
Save pyrsmk/4c61e7d0ed27689553b097fa51356711 to your computer and use it in GitHub Desktop.
Eslint task for Just
const { CLIEngine } = require('eslint')
const { logger } = require('just-task')
module.exports = options => {
const eslint = new CLIEngine()
const formatter = eslint.getFormatter()
const { results } = eslint.executeOnFiles([options.glob])
if (results.reduce((value, item) => value + item.errorCount, 0)) {
logger.info(formatter(results))
throw new Error('Linter has found errors')
} else if (results.reduce((value, item) => value + item.warningCount, 0)) {
logger.info(formatter(results))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment