getESLint.d.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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').PluginOptions &
  36. import('eslint').ESLint.Options;
  37. export type AsyncTask = () => Promise<void>;
  38. export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
  39. export type Worker = JestWorker & {
  40. lintFiles: LintTask;
  41. };
  42. export type Linter = {
  43. threads: number;
  44. ESLint: ESLint;
  45. eslint: ESLint;
  46. lintFiles: LintTask;
  47. cleanup: AsyncTask;
  48. };
  49. import JestWorker from 'jest-worker';