@@ -2,6 +2,8 @@ const { cpus } = require('os');
22
33const { Worker : JestWorker } = require ( 'jest-worker' ) ;
44
5+ // @ts -ignore
6+ const { setup, lintFiles } = require ( './worker' ) ;
57const { getESLintOptions } = require ( './options' ) ;
68const { jsonStringifyReplacerSortKeys } = require ( './utils' ) ;
79
@@ -13,7 +15,7 @@ const cache = {};
1315/** @typedef {import('./options').Options } Options */
1416/** @typedef {() => Promise<void> } AsyncTask */
1517/** @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 */
1719/** @typedef {JestWorker & {lintFiles: LintTask} } Worker */
1820
1921/**
@@ -22,24 +24,16 @@ const cache = {};
2224 */
2325function loadESLint ( options ) {
2426 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+ } ) ;
3032
3133 return {
3234 threads : 1 ,
33- ESLint ,
35+ lintFiles ,
3436 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- } ,
4337 // no-op for non-threaded
4438 cleanup : async ( ) => { } ,
4539 } ;
@@ -58,7 +52,13 @@ function loadESLintThreaded(key, poolSize, options) {
5852 const workerOptions = {
5953 enableWorkerThreads : true ,
6054 numWorkers : poolSize ,
61- setupArgs : [ { eslintPath, eslintOptions : getESLintOptions ( options ) } ] ,
55+ setupArgs : [
56+ {
57+ eslintPath,
58+ configType : options . configType ,
59+ eslintOptions : getESLintOptions ( options ) ,
60+ } ,
61+ ] ,
6262 } ;
6363
6464 const local = loadESLint ( options ) ;
0 commit comments