0.4.0 • Published 4 years ago

weslint v0.4.0

Weekly downloads
134
License
MIT
Repository
github
Last release
4 years ago

weslint npm

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>

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')
}