Created
July 23, 2019 14:02
-
-
Save pyrsmk/4c61e7d0ed27689553b097fa51356711 to your computer and use it in GitHub Desktop.
Eslint task for Just
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
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