0.4.0 • Published 4 years ago
weslint v0.4.0
weslint
Worker Threads + ESlint.
:warning: Node.js v10 needs an --experimental-worker
flag.
Install
$ yarn add weslint
API
type TWeslintOptions = {
files: string[],
maxThreadCount?: number,
formatter?: string,
eslint?: CLIEngine.Options,
}
type TWeslintResult = {
hasErrors: boolean,
hasWarnings: boolean,
formattedReport: string,
}
const weslint: (options: TWeslintOptions) => Promise<TWeslintResult>
files
– array of file pathsmaxThreadCount
–cpus().length
by defaultformatter
– ESLint formatter nameeslint
– ESLint CLIEngine options
Usage
import { weslint } from 'weslint'
const result = await weslint({
files: ['./file1.ts', './file2.ts']
})
if (result.hasErrors || result.hasWarnings) {
console.log(result.formattedReport)
}
if (result.hasErrors) {
throw new Error('oops')
}