@@ -2,6 +2,8 @@ const { cpus } = require('os');
2
2
3
3
const { Worker : JestWorker } = require ( 'jest-worker' ) ;
4
4
5
+ // @ts -ignore
6
+ const { setup, lintFiles } = require ( './worker' ) ;
5
7
const { getESLintOptions } = require ( './options' ) ;
6
8
const { jsonStringifyReplacerSortKeys } = require ( './utils' ) ;
7
9
@@ -13,7 +15,7 @@ const cache = {};
13
15
/** @typedef {import('./options').Options } Options */
14
16
/** @typedef {() => Promise<void> } AsyncTask */
15
17
/** @typedef {(files: string|string[]) => Promise<LintResult[]> } LintTask */
16
- /** @typedef {{threads: number, ESLint: ESLint, eslint: ESLint, lintFiles: LintTask, cleanup: AsyncTask} } Linter */
18
+ /** @typedef {{threads: number, eslint: ESLint, lintFiles: LintTask, cleanup: AsyncTask} } Linter */
17
19
/** @typedef {JestWorker & {lintFiles: LintTask} } Worker */
18
20
19
21
/**
@@ -22,24 +24,16 @@ const cache = {};
22
24
*/
23
25
function loadESLint ( options ) {
24
26
const { eslintPath } = options ;
25
-
26
- const { ESLint } = require ( eslintPath || 'eslint' ) ;
27
-
28
- // Filter out loader options before passing the options to ESLint.
29
- const eslint = new ESLint ( getESLintOptions ( options ) ) ;
27
+ const eslint = setup ( {
28
+ eslintPath,
29
+ configType : options . configType ,
30
+ eslintOptions : getESLintOptions ( options ) ,
31
+ } ) ;
30
32
31
33
return {
32
34
threads : 1 ,
33
- ESLint ,
35
+ lintFiles ,
34
36
eslint,
35
- lintFiles : async ( files ) => {
36
- const results = await eslint . lintFiles ( files ) ;
37
- // istanbul ignore else
38
- if ( options . fix ) {
39
- await ESLint . outputFixes ( results ) ;
40
- }
41
- return results ;
42
- } ,
43
37
// no-op for non-threaded
44
38
cleanup : async ( ) => { } ,
45
39
} ;
@@ -58,7 +52,13 @@ function loadESLintThreaded(key, poolSize, options) {
58
52
const workerOptions = {
59
53
enableWorkerThreads : true ,
60
54
numWorkers : poolSize ,
61
- setupArgs : [ { eslintPath, eslintOptions : getESLintOptions ( options ) } ] ,
55
+ setupArgs : [
56
+ {
57
+ eslintPath,
58
+ configType : options . configType ,
59
+ eslintOptions : getESLintOptions ( options ) ,
60
+ } ,
61
+ ] ,
62
62
} ;
63
63
64
64
const local = loadESLint ( options ) ;
0 commit comments