run-eslint
Execute ESLint with a simplified API
const runEslint = ; ;
Without this module,
const CLIEngine = ; const cli = fix: true;const report = cli;const messages = clireportresults; CLIEngine; if reporterrorCount !== 0 throw messages; if reportwarningCount !== 0 console;
Installation
npm install run-eslint
API
const runEslint = ;
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.
;/* throws an Error: ESLint found problems in 2 files. /Users/shinnn/invalid/a.js1:1 error Parsing error: Unexpected token } /Users/shinnn/files/b.js1:1 error 'v' is not defined no-undef2:2 error Missing semicolon semi ✖ 3 problems (3 errors, 0 warnings)1 error and 0 warnings potentially fixable with the `--fix` option.`*/
When every problem is a warn
level, it just print messages to the stdout instead of throwing an Error
.
options.formatter
Type: string
(a built-in formatter name or a path to a custom formatter)
Default: same as the CLIEngine#getFormatter()
's default
Set the formatter used when reporting problems.
License
ISC License © 2018 Shinnosuke Watanabe