Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threads #39

Merged
merged 3 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions declarations/getESLint.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
/** @typedef {import('eslint').ESLint} ESLint */
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
/** @typedef {import('./options').Options} Options */
/** @typedef {() => Promise<void>} AsyncTask */
/** @typedef {(files: string|string[]) => Promise<LintResult[]>} LintTask */
/** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
/** @typedef {{threads: number, ESLint: ESLint, eslint: ESLint, lintFiles: LintTask, cleanup: AsyncTask}} Linter */
/**
* @param {Options} options
* @returns {{ESLint: ESLint, eslint: ESLint}}
* @returns {Linter}
*/
export default function getESLint(
options: Options
): {
ESLint: import('eslint').ESLint;
eslint: import('eslint').ESLint;
};
export function loadESLint(options: Options): Linter;
/**
* @param {number} poolSize
* @param {Options} options
* @returns {Linter}
*/
export function loadESLintThreaded(poolSize: number, options: Options): Linter;
/**
* @param {Options} options
* @returns {Linter}
*/
export default function getESLint({ threads, ...options }: Options): Linter;
export type ESLint = import('eslint').ESLint;
export type LintResult = import('eslint').ESLint.LintResult;
export type Options = {
context?: string | undefined;
emitError?: boolean | undefined;
Expand All @@ -26,4 +38,18 @@ export type Options = {
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: import('./options').OutputReport | undefined;
threads?: number | boolean | undefined;
};
export type AsyncTask = () => Promise<void>;
export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
export type Worker = JestWorker & {
lintFiles: LintTask;
};
export type Linter = {
threads: number;
ESLint: ESLint;
eslint: ESLint;
lintFiles: LintTask;
cleanup: AsyncTask;
};
import JestWorker from 'jest-worker';
1 change: 1 addition & 0 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ export type Options = {
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: import('./options').OutputReport | undefined;
threads?: number | boolean | undefined;
};
5 changes: 4 additions & 1 deletion declarations/linter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
/** @typedef {(files: string|string[]) => void} Linter */
/**
* @param {Options} options
* @param {Compilation} compilation
* @returns {{lint: Linter, report: Reporter}}
*/
export default function linter(
options: Options
options: Options,
compilation: Compilation
): {
lint: Linter;
report: Reporter;
Expand All @@ -41,6 +43,7 @@ export type Options = {
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: import('./options').OutputReport | undefined;
threads?: number | boolean | undefined;
};
export type FormatterFunction = (
results: import('eslint').ESLint.LintResult[],
Expand Down
2 changes: 2 additions & 0 deletions declarations/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @property {boolean=} lintDirtyModulesOnly
* @property {boolean=} quiet
* @property {OutputReport=} outputReport
* @property {number|boolean=} threads
*/
/**
* @param {Options} pluginOptions
Expand Down Expand Up @@ -65,4 +66,5 @@ export type Options = {
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: OutputReport | undefined;
threads?: (number | boolean) | undefined;
};
12 changes: 12 additions & 0 deletions declarations/worker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export type setupOptions = {
/**
* - import path of eslint
*/
eslintPath?: string | undefined;
/**
* - linter options
*/
eslintOptions?: ESLintOptions | undefined;
};
export type ESLint = import('eslint').ESLint;
export type ESLintOptions = import('eslint').ESLint.Options;
Loading