getESLint.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /** @typedef {import('eslint').ESLint} ESLint */
  2. /** @typedef {import('eslint').ESLint.LintResult} LintResult */
  3. /** @typedef {import('./options').Options} Options */
  4. /** @typedef {() => Promise<void>} AsyncTask */
  5. /** @typedef {(files: string|string[]) => Promise<LintResult[]>} LintTask */
  6. /** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
  7. /** @typedef {{threads: number, ESLint: ESLint, eslint: ESLint, lintFiles: LintTask, cleanup: AsyncTask}} Linter */
  8. /**
  9. * @param {Options} options
  10. * @returns {Linter}
  11. */
  12. export function loadESLint(options: Options): Linter;
  13. /**
  14. * @param {string|undefined} key
  15. * @param {number} poolSize
  16. * @param {Options} options
  17. * @returns {Linter}
  18. */
  19. export function loadESLintThreaded(
  20. key: string | undefined,
  21. poolSize: number,
  22. options: Options
  23. ): Linter;
  24. /**
  25. * @param {string|undefined} key
  26. * @param {Options} options
  27. * @returns {Linter}
  28. */
  29. export default function getESLint(
  30. key: string | undefined,
  31. { threads, ...options }: Options
  32. ): Linter;
  33. export type ESLint = import('eslint').ESLint;
  34. export type LintResult = import('eslint').ESLint.LintResult;
  35. export type Options = import('./options').Options;
  36. export type AsyncTask = () => Promise<void>;
  37. export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
  38. export type Worker = JestWorker & {
  39. lintFiles: LintTask;
  40. };
  41. export type Linter = {
  42. threads: number;
  43. ESLint: ESLint;
  44. eslint: ESLint;
  45. lintFiles: LintTask;
  46. cleanup: AsyncTask;
  47. };
  48. import { Worker as JestWorker } from 'jest-worker';