Licence
ISC
Version
0.0.1
Deps
2
Size
5 kB
Vulns
2
Weekly
0
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-eslint
API
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 error
License
ISC License 2018 Shinnosuke Watanabe