0.0.1 • Published 7 years ago
compile-pug-file v0.0.1
run-eslint
Execute ESLint with a simplified API
const runEslint = require('run-eslint');
runEslint(['src/'], {
fix: true,
formatter: 'codeframe'
});Without this module,
const {CLIEngine} = require('eslint');
const cli = new CLIEngine({fix: true});
const report = cli.executeOnFiles(['src/']);
const messages = cli.getFormatter('codeframe')(report.results);
CLIEngine.outputFixes(report);
if (report.errorCount !== 0) {
throw new Error(messages);
}
if (report.warningCount !== 0) {
console.log(messages);
}Installation
npm install run-eslintAPI
const runEslint = require('run-eslint');runEslint(paths, options)
paths: string[] (file and/or directory paths, directly passed to CLIEngine#executeOnFiles())
options: Object (CLIEngine options)
Return: Object (return value of CLIEngine#executeOnFiles())
It lints files, fixes problems when fix option is true, throws an error with the formatted messages.
runEslint(['.']);
// throws an errorLicense
ISC License © 2018 Shinnosuke Watanabe