0.0.1 • Published 5 years ago

compile-pug-file v0.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

run-eslint

npm version Build Status Coverage Status

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

Use npm.

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